Preplp
Daily Python
Day 2Python~30 min

Variables & Types

Strings, numbers, booleans, and type conversion

Track progress0/15 days
x

What you'll learn

strintfloatbooltype()int()f-strings
  • Store data in variables with meaningful names
  • Identify common Python data types
  • Convert between string and integer
  • Build a personalized greeting with age and color

Lesson & examples

Read the code, then the explanation — try changing values before the project.

Basic types
name = "Vivian"      # str
age = 42             # int
height = 5.8         # float
is_student = False   # bool

print(type(name))
print(type(age))
Type conversion
age = "42"
myAge = int(age)
print(myAge + 5)  # 47

input() always returns a string. Use int() before doing math with numbers.

Three ways to format text
name = "Vivian"
print("Hello, " + name + "!")
print("Hello, {}!".format(name))
print(f"Hello, {name}!")

Today's exercise: Personalized Greeting Program

Ask for the user's name, age, and favorite color. Convert age to a number and print a friendly message.

Steps

  1. 1

    Collect user details

    Ask for name (str), age (convert with int()), and favorite color (str).

  2. 2

    Build the message

    Print a header and use an f-string to mention their name, age, and color.

  3. 3

    Encourage the learner

    Add a final line celebrating that they're ready for Python.

Full project source — copy into a folder or use the zip above

starter.py
# Personalized Greeting Program

name = input("What is your name? ")
age = int(input("How old are you? "))
color = input("What is your favorite color? ")

print("\n---- Personalized Greeting ----")
print(f"Hello, {name}!")
print(f"You are {age} years old and {color} is a beautiful color!")
print("You're now ready to start your Python adventure.")

Code explained

  1. 1.int() on age

    input() always returns a string. int() converts the user's age so you can do math and comparisons later.

    Snippet
    age = int(input("How old are you? "))
  2. 2.f-string with multiple variables

    One f-string can include name, age, and color — each {variable} is replaced at runtime.

Sample output

What is your name? Sam
How old are you? 22
What is your favorite color? blue

---- Personalized Greeting ----
Hello, Sam!
You are 22 years old and blue is a beautiful color!
You're now ready to start your Python adventure.

One rehearsal platform

Certification mocks, daily lessons, project labs, and in-browser drills

Structured for exam day and portfolio proof — timed tests, guided builds, and quick reps on one platform.