If/elif/else
Printing & str()
input() & Conversion
PEMDAS & Tiny Math
Debug This!
100

What does elif do in an if / elif / else chain, and why does order matter?

elif adds another condition to the same chain; the first True branch runs and the rest are skipped, so order controls which branch “wins.”

100

Join text and a name stored in student_name

print("Student: " + student_name)

100

Write a full-question prompt asking for a name.

input("What is your name? ")

100

Evaluate: 10 + 2 * 3

16

100

Fix: Print("Hi")

print("Hi")

200

What Prints:

n = 70

if n < 60:

    print("Below 60")

elif n <= 70:

    print("60 to 70")

else:

    print("Above 70")

60 to 70

200

Fix: print("Total: $" + total)

print("Total: $" + str(total))

200

Read an age as an integer

age = int(input("How old are you right now? "))

200

Average of 84 and 90 with correct parentheses

(84 + 90) / 2

200

student name = "Ava"

student_name = "Ava"

300

The Following prints 2 times, why?

temp = 65

if temp <= 69:

    print("Cool")

if temp <= 85:

    print("Warm")

else:

    print("Hot")

Change the second if to elif

300

score = 95

print("Honor Roll: " + str(score >= 90))

Honor Roll: True

300

Does this succeed, and what value?

age_text = "   15  "

age = int(age_text)


Succeeds → 15 (leading/trailing spaces are allowed for int())

300

Evaluate: 7 + 8 % 3 * 2

11 (8 % 3 = 2; 2*2 = 4; 7 + 4 = 11)

300

What is wrong with this?

avg = 84 + 90

print("Average: " + str(avg) / 2)



print("Average: " + str(avg / 2))

400

What’s wrong with this grade chain, and how do you fix it

score = 92

if score >= 70:

    print("Pass")

elif score >= 90:

    print("A")

else:

    print("Try again")

The order is wrong—score >= 70 catches 92 first. Put score >= 90 before >= 70.

400

With g = 10, give one line (no commas) that prints exactly Grade 10/10

print("Grade " + str(g) + "/10") (any equivalent using + and str() is fine)

400

Ask minutes (int) and seconds (int). Print "Total minutes: " as a decimal (e.g., 1.5 for 1 min 30 s)

m = int(input("How many minutes? "))

s = int(input("How many seconds? "))

print("Total minutes: " + str(m + s/60.0))

400

If two waters cost $1.50 each and a bar is $2.25, with tax 8.5%, what is the final total rounded to 2 decimals?

round((2*1.50 + 2.25) * 1.085, 2) → 5.70

400

price = input("What is the price of one snack (e.g., 1.50)? ")

if price <= 2.00:

    print("Affordable")

elif price <= 10.00:

    print("Pricey")

else:

    print("Luxury")


float()

500

Why will this crash for valid input, and what line should be corrected?

age = input("What is your age in years? ")

if age < 5:

    label = "Free"

elif age <= 12:

    label = "Child"

elif age <= 64:

    label = "Adult"

else:

    label = "Senior"

input() returns a string; comparing string to number crashes. Fix first line to
age = int(input("What is your age in years? "))

500

x = 3

y = 2

msg = "Sum: " + str(x + y)

x = "3"

print(msg)

print("Sum: " + x + str(y))

Sum: 5
Sum: 32

500

Ask for a nickname. If the user just presses Enter, use "Anonymous". Print Welcome, NAME!

nick = input("What is your nickname? ")

if nick == "":

    nick = "Anonymous"

print("Welcome, " + nick + "!")

500

((25 % 7) * (18 / 3) + 6) / ((14 - 8) + (21 % 4))

30 / 7 ≈ 4.2857142857

500

adult = int(input("How many adult tickets? "))

student = int(input("How many student tickets? "))

adult_price = input("What is the adult price (e.g., 12.50)? ")

student_price = float(input("What is the student price (e.g., 8.00)? "))


subtotal = adult * adult_price + student * student_price

fee = 2.00

total = subtotal + fee


print("Total: $" + round(total, 2))

adult_price = float(...)