What are the 3 parts of locker_number = 127?
name / = / value
Join text and a name stored in student_name
print("Student: " + student_name)
Write a full-question prompt asking for a name.
input("What is your name? ")
Evaluate: 10 + 2 * 3
16
Fix: Print("Hi")
print("Hi")
What type is "42" vs 42?
"42" → str, 42 → int
Fix: print("Total: $" + total)
print("Total: $" + str(total))
Read an age as an integer
age = int(input("How old are you right now? "))
Average of 84 and 90 with correct parentheses
(84 + 90) / 2
student name = "Ava"
student_name = "Ava"
What type does input() return?
str (string)
Why do we need str() here?
Because + can only join strings; numbers must be converted
Why might int(input(...)) crash?
Blank input or non-digits (e.g., “abc”)
Show a division that gives 1.5 using 3 and 2
3/2.0 or float(3)/2
Predict output:
G=10
Write a valid variable name for grade level
grade_level
Print exactly: Grade: 10 using the variable g = 10
print("Grade: " + str(g))
Read price (float) and qty (int), store in price, qty
price = float(input(...)) and qty = int(input(...))
Round 5.678 to two decimals in a print line with $
print("Total: $" + str(round(5.678, 2)))
Fix:
qty = int(input("How many? "))
Change "15" (string) into a number you can add with
int("15") (or float("15"))
Show two different correct prints for score = 95
"Score: " + str(score) and "95" via print("Score: " + str(95))
Student presses Enter on a prompt. What does input() return?
Empty string ""
Compute subtotal for qty and price and print it with $.
print("Subtotal: $" + str(qty * price)) (if qty/price already numeric)
Fix order: avg = 80 + 90 / 2
avg = (80 + 90) / 2