Phase 1 · Programming Fundamentals
Variables, Types, Print & Input
Write your first real Python programs—store data, print it, and talk to the user.
On this page
Variables: named boxes for values
A variable stores a value under a name so you can reuse it later. In Python you create one with a simple assignment:
Names should be readable: use snake_case like user_name or total_price. Avoid starting with a number or using reserved words like class or print.
name = "Ada"
age = 28
height_m = 1.68
is_student = True
print(name)
print(age)You do not declare types upfront in basic Python. The value you assign decides the type.
Core data types
Python has a few types you will use constantly:
- str — text in quotes: "hello"
- int — whole numbers: 42
- float — decimals: 3.14
- bool — True or False
Use type(value) to inspect a value’s type while learning.
city = "Lagos"
year = 2026
temp = 36.5
online = False
print(type(city)) # <class 'str'>
print(type(year)) # <class 'int'>
print(type(temp)) # <class 'float'>
print(type(online)) # <class 'bool'>age_text = "21"
age = int(age_text)
price = float("9.99")
label = str(100)
print(age + 1)
print(price * 2)
print("Room " + label)int("3.5") fails. Convert decimals with float first, or use int(float("3.5")).
print(): show results
print() sends text to the console. You can print multiple values separated by commas—Python inserts spaces between them.
f-strings (formatted string literals) are the cleanest way to mix variables into text.
product = "keyboard"
price = 49.99
print("Hello, world!")
print(product, price)
print(f"The {product} costs ${price}")input(): talk to the user
input(prompt) shows a message and waits for the user to type something. It always returns a string—even if they type a number.
Convert with int() or float() when you need math.
name = input("What is your name? ")
print(f"Nice to meet you, {name}!")
age_text = input("How old are you? ")
age = int(age_text)
print(f"Next year you will be {age + 1}.")In the browser Try It panel, input() uses a prompt dialog. On your machine it reads from the terminal.
Practice
Mini challenge: personal intro
Ask for the user’s name and favorite language, then print a one-line intro using an f-string. Example output: Ada loves Python.
name = input("Your name: ")
language = input("Favorite language: ")
# TODO: print an f-string intro
Interactive
Try It in the browser
Powered by Pyodide
Create three variables (a string, an int, and a float) and print each one. Then print a single f-string that includes all three.
Output
—
Errors
—
Check understanding
Lesson quiz
Score 4/5 or higher to mark this day complete.