Python, Concept by Concept › Checkpoint 01: Foundations
Questions: Checkpoint 01: Foundations
Complete all seven exercises. The balance is two output-and-variables exercises, two numbers-and-arithmetic exercises, two decisions exercises, and one traceback-reading exercise. Follow each specification and produce the exact output shown from the fixed given values.
Each question ends with a Real version note showing how the program can read its values with input().
Question 1: Name Card
A card stores a name and hometown separately, then places both values in one sentence.
Specification: Given name and hometown, use one f-string to print exactly <name> is from <hometown>.
Worked sample — given values:
name = "Maya"
hometown = "Oakland"
Expected output:
Maya is from Oakland.
Real program
The real program reads a name and a hometown on separate lines with input().
How this is checked: Checked by comparing what your program prints with the expected output.
Answer format: one line
Question 2: Labeled Item
A shelf label joins fixed text with a saved item name.
Specification: Given item, use string concatenation with + to print exactly Item: <item>. Do not use an f-string.
Worked sample — given values:
item = "markers"
Expected output:
Item: markers
Real program
The real program reads an item name on one line with input().
How this is checked: Checked by comparing what your program prints with the expected output.
Answer format: one line
Question 3: Hours and Minutes
A duration needs complete hours and leftover minutes.
Specification: Given the non-negative integer total_minutes, use // and % to print exactly <hours> hours <minutes> minutes.
Worked sample — given values:
total_minutes = 155
Expected output:
2 hours 35 minutes
Real program
The real program reads a total number of minutes on one line with input().
How this is checked: Checked by comparing what your program prints with the expected output.
Answer format: one line
Question 4: Converted Average
Two score values arrived as text. They must become integers before regular division finds their average.
Specification: Given first_text and second_text, convert each with int(), add the numbers, divide by 2 with /, and print exactly Average: <average>. Show Python's exact float output.
Worked sample — given values:
first_text = "8"
second_text = "12"
Expected output:
Average: 10.0
Real program
The real program reads two score texts with input(), converts them with int, and prints the average.
How this is checked: Checked by comparing what your program prints with the expected output.
Answer format: one line
Question 5: Ordered Score Ladder
A score receives the first level whose threshold it reaches. The checks overlap, so their order determines the label.
Specification: Given score, use exactly one if/elif/elif/else ladder. Check score >= 90 for Level A first, score >= 80 for Level B next, and score >= 70 for Level C next; otherwise print Keep practicing.
Worked sample — given values:
score = 94
Expected output:
Level A
Notice
94 also reaches the lower thresholds. The highest threshold must appear first because the first matching branch wins.
Real program
The real program reads a score on one line with input().
How this is checked: Checked by comparing what your program prints with the expected output.
Answer format: one line
Question 6: Range and Entry Test
An entry is approved for ages 10 through 13 when the person also has either a pass or an invitation.
Specification: Given age, has_pass, and has_invitation, use age >= 10 and age <= 13 for the inclusive range. Join it with the choice (has_pass or has_invitation), keeping that choice in parentheses. Print Entry approved when the full condition is true; otherwise print Entry denied.
Worked sample — given values:
age = 12
has_pass = False
has_invitation = True
Expected output:
Entry approved
Real program
The real program reads an age, a pass answer (yes/no), and an invitation answer (yes/no) on separate lines with input().
How this is checked: Checked by comparing what your program prints with the expected output.
Answer format: one line
Question 7: Read the Final Traceback Line
A program tries to join text and an integer with +:
points = 7
print("Points: " + points)
The final traceback line begins like this:
TypeError: can only concatenate str ... to str
Specification: Read the final traceback line and print only the error type.
Worked sample — given values:
The final traceback line begins with TypeError.
Expected output:
TypeError
How this is checked: Checked by comparing what your program prints with the expected output.
Answer format: one line