Course Content
Module 2: Variables and Data Types
๐ŸŽฏ Module Objective: To help learners understand how to store, manage, and work with different types of data in Python using variables, and how to recognize and convert between data types.
0/3
Topic 3: Control Flow
๐ŸŽฏ Module Objective This module introduces learners to Python operators used in calculations, comparisons, and logic. Learners will understand how expressions are evaluated and how to build logical conditions using operators.
0/2
Module 4: Control Flow
๐ŸŽฏ Module Objective: This module introduces the concept of decision-making and repetition in Python programs using: if-else statements for loops while loops break, continue and basic loop control
0/3
Module 5: Functions
๐ŸŽฏ Module Objective: This module helps learners understand how to organize code using functions. Theyโ€™ll learn how to: Create and call functions Use parameters and return values Understand the concept of scope Get introduced to recursion
0/2
Module 6: Lists and Tuples
๐ŸŽฏ Module Objective: This module introduces learners to two important data collection types in Python โ€” lists and tuples. Learners will: Create, access, and modify lists Use list methods like append(), remove(), sort() Understand the difference between mutable (lists) and immutable (tuples)
0/2
Module 7: Dictionaries and Sets
๐ŸŽฏ Module Objective: This module introduces two powerful Python data types: Dictionaries: for storing keyโ€“value pairs Sets: for storing unordered, unique items Learners will: Understand the syntax and usage of dictionaries and sets Perform operations like adding, removing, updating Use dictionary methods (get(), update(), keys(), values())
0/2
Module 8: File Handling
๐ŸŽฏ Module Objective: This module introduces learners to the basics of file handling โ€” reading from and writing to text files using Python. Learners will: Open and read from a file Write to and append content in a file Use the with statement for safe file handling
0/1
๐Ÿ› ๏ธ Module 9: Error Handling in Python
๐ŸŽฏ Module Objective: This module introduces learners to error handling in Python โ€” a critical skill for writing stable and reliable programs. Learners will: Understand what exceptions are Learn how to use try, except, else, and finally Handle common Python errors (e.g., ZeroDivisionError, ValueError, FileNotFoundError) Write code that doesnโ€™t crash when unexpected issues occur
0/1
Module 10: Final Project
๐ŸŽฏ Module Objective: To help learners consolidate and apply all the skills theyโ€™ve gained throughout the course by building a small, real-world project. Upon successful completion, learners can earn a course completion certificate via Tutor LMS.
0/4
Python for Absolute Beginners: From Zero to Hero
About Lesson

๐ŸŽฏ Learning Objectives

By the end of this lesson, learners will be able to:

  • Use the input() function to receive user input

  • Understand that input() returns a string by default

  • Convert strings to other data types (int, float, bool)

  • Handle basic type conversion errors


๐Ÿ“š Lesson Content


๐Ÿ”น What is input() in Python?

The input() function lets you get data from the user during program execution.

python
name = input("What is your name? ")
print("Hello", name)

โœ… Whatever the user types is always returned as a string, even if it’s a number.


๐Ÿ”ธ Type Conversion (Type Casting)

Type conversion means changing the data type of a variable or value.

Python provides built-in functions:

  • int() โ†’ Convert to integer

  • float() โ†’ Convert to float

  • str() โ†’ Convert to string

  • bool() โ†’ Convert to boolean


๐Ÿ”„ Converting Input

Example: Get a number from the user and double it

python
user_input = input("Enter a number: ")
number = int(user_input)
print("Double of your number is:", number * 2)

โœ… You must convert input if you want to treat it as a number.


๐Ÿ’ฅ Common Mistake

python
age = input("Enter your age: ")
print(age + 5) # โŒ Error: Can't add int to str

โœ… Fix:

python
age = int(input("Enter your age: "))
print(age + 5)

๐Ÿ” Example: All Data Types with Input

python
name = input("Your name: ") # str
age = int(input("Your age: ")) # int
height = float(input("Your height: ")) # float
is_student = input("Are you a student (yes/no)? ") == "yes" # bool

โš ๏ธ Caution: Input Errors

If you try to convert a non-numeric string to int or float, it will raise a ValueError.

python
num = int("abc") # โŒ ValueError

๐Ÿ› ๏ธ We’ll learn error handling later!


๐Ÿ“ Assignment

Create a small script that:

  1. Asks the user for their name, age, and weight

  2. Converts age to int and weight to float

  3. Prints a summary like:
    "Hello Alice, you are 24 years old and weigh 55.5 kg."

Scroll to Top