# --- L1: Print & Strings ---
# Q1: Print Hello, world!
print("Hello, world!")
# Q2: Print your name
print("My name is Alex")
# Q3: Concatenation with +
name = "Alex"
print("My name is " + name)
# Q4: f-string example
print(f"My name is {name}")
# Q5: Two print lines for game and animal
print("My favorite game is Minecraft")
print("My favorite animal is cat")
# --- L2: Data Types ---
# Q1: Integer
number = 7
# Q2: Float
decimal = 3.5
# Q3: String
word = "cat"
# Q4: Check type of number
print(type(5))
# Q5: Check type of string
print(type("hello"))
# --- L3: User Input ---
# Q1: Ask for name
name = input("What is your name? ")
# Q2: Ask for age
age = input("How old are you? ")
# Q3: Convert age to integer
age = int(age)
# Q4: Ask for favorite food
food = input("What is your favorite food? ")
# Q5: Print sentence using all three
print(f"Your name is {name}, you are {age}, and you like {food}.")
# --- L4: Variables ---
# Q1: Variable for name
name = "Alex"
# Q2: Variable for age
age = 12
# Q3: Print both in one sentence
print(f"My name is {name} and I am {age} years old.")
# Q4: Change age and print again
age = 13
print(f"My name is still {name} and now I am {age}.")
# Q5: Add favorite color and print all
color = "blue"
print(f"My name is {name}, I am {age}, and my favorite color is {color}.")
# --- L5: Conditions & Operators ---
# Q1: 5 == 5
print(5 == 5)
# Q2: 6 != 3
print(6 != 3)
# Q3: 10 > 2 and 10 < 20
print(10 > 2 and 10 < 20)
# Q4: Ask for two numbers and compare
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
if a > b:
print("First number is bigger")
elif a < b:
print("Second number is bigger")
else:
print("They are equal")
# Q5: Say equal or different
if a == b:
print("The numbers are equal")
else:
print("They are different")
# --- L6: if / elif / else ---
# Q1: Number greater than 10
num = int(input("Enter a number: "))
if num > 10:
print("The number is greater than 10")
# Q2: Grade checker
score = int(input("Enter your score: "))
if score >= 90:
print("Grade: A")
elif score >= 80:
print("Grade: B")
else:
print("Grade: C")
# Q3: Under 13 = child
age = int(input("Enter your age: "))
if age < 13:
print("You are a child")
# Q4: 13–17 = teen
if age >= 13 and age <= 17:
print("You are a teenager")
# Q5: Full age checker
if age < 13:
print("You are a child")
elif age <= 17:
print("You are a teenager")
else:
print("You are an adult")
# --- L7: Loops ---
# Q1: for loop 0 to 4
for i in range(5):
print(i)
# Q2: while loop 0 to 4
count = 0
while count < 5:
print(count)
count += 1
# Q3: for loop with break
for i in range(10):
if i == 3:
break
print(i)
# Q4: loop with continue
for i in range(5):
if i == 2:
continue
print(i)
# Q5: while loop asking for "go"
text = ""
while text != "go":
text = input("Type 'go': ")