Python by Projects › High-Score Hall of Fame
Exercises: High-Score Hall of Fame
The arcade's scrap-paper score board is overflowing. Build a Python list that can remember new scores, show every entry, and keep the hall ready for the next player. Write your work in each blank code cell.
Exercise 1: Build the Board from Scratch
Create a list named scores with the integer scores 700, 1250, 980, and 1420. Store 1360 in new_score, append it, and print the whole score board in an f-string. Then print new_score in scores so the membership result appears directly as True or False.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: Checked by tests that run your code.
Exercise 2: Champion and Rookie
Start with scores = [1200, 850, 990, 1500]. Use max to find the champion score and min to find the rookie score. Calculate the decimal midpoint between them with (champion + rookie) / 2. Sort the list top-first, then print scores[0], scores[-1], and the midpoint in f-strings. Finally, write an if/else that prints whether the champion is greater than the rookie.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 3: Read an IndexError, Then Number the Score Sheet
Use the unsorted list scores = [1200, 850, 990, 1500]. In the first blank cell, deliberately write scores[len(scores)], predict the last line of the traceback, then run it to check your prediction. Expect IndexError: list index out of range. In the second blank cell, fix the bug by safely printing the last score with the negative index scores[-1]. Then loop through the positions with for i in range(len(scores)): and print each item exactly like Entry #1: 1200, using i + 1 and scores[i]. Keep the scores in arrival order.
This is a trace/debug exercise — fixed data on purpose, no input version.
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 4: Add My Score and Keep the Hall Ranked
Define add_my_score(scores, new_score) so the score is a parameter. Inside the function, append new_score, immediately sort the same list top-first with .sort(reverse=True), and return scores. Start with [1500, 1200, 990, 850], read a score with int(input("What score did you earn? ")), call the function, and print the ranked list and its champion at scores[0]. This cell waits for your typing, so run it yourself and enter a score such as 1310.
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 5: Label an Already-Sorted Board
Define board_line(place, score) with two parameters. Return exactly "Place " + str(place) + ": " + str(score). Use the already-sorted top-first list scores = [1500, 1200, 990, 850]. Loop with for place in range(len(scores)): and print the helper's result for each score, using place + 1 for the displayed place.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: Checked by tests that run your function board_line.
Exercise 6: Guard Against a Repeated Score
Start with the already-ranked list scores = [1500, 1200, 990, 850]. Read new_score with int(input("New score: ").strip()), then print new_score in scores so the membership result itself appears as a boolean value. While the score is already in the list, print a helpful message and ask again. Once it is new, append it, sort the board top-first, and use an if/else to print whether it became the champion at scores[0]. This cell waits for your typing, so run it yourself: try 990, 1200, 850, then 1310 — the first three are already on the board, so the loop asks again each time.
More Practice — Homework: Exercises 7–9
Exercises 7–9 are extra core practice, not Challenges. Complete them after Lesson 3. The algorithm-pattern exercises and extra loop drills follow in the Algorithm Extension.
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 7: Build an Ascending Score Report
Start with scores = [900, 450, 1200, 1050]. Read a player name with input, then clean it with .strip().upper() and print it with string concatenation. Read one score with a second input and convert it to an integer. Append the score and call exactly scores.sort() with empty parentheses so the board is ascending. Loop through range(len(scores)) and print each line with string concatenation in the form "Entry " + str(i + 1) + ": " + str(scores[i]). This cell waits for your typing, so run it yourself with sample answers.
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 8: Why Did `best` Become `None`?
Start with scores = [900, 450, 1200, 1050]. First write best = scores.sort() and print both best and scores. Predict the two printed values before you run the cell. Then fix the code: reset the same unsorted list, call .sort() on its own line, make best hold the sorted board, and print best again.
This is a trace/debug exercise — fixed data on purpose, no input version.
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 9: Fill a Bonus Board to Its Target
Start with waiting_scores = [300, 450, 275, 600], an empty bonus_board, i = 0, and total = 0. Write a while loop that continues while total < 1000. Each trip through the loop must read waiting_scores[i], append it to bonus_board, add it to the running total, and add 1 to i. After the loop, print the board, its last score with bonus_board[-1], and the decimal average total / len(bonus_board) in f-strings.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Algorithm Extension
Extra loop practice — optional enrichment: these drills reuse the same loop shapes on small fixed data, so try as many as you like.
Exercise 10: Total and Average
Start with scores = [600, 800, 1000] and total = 0. Use one loop to add every score to the accumulator. Then calculate average = total / len(scores) and use max(scores) for the best score. Store average >= 700 in reached_goal. Print the total, decimal average, best score, and the boolean value in f-strings.
Pattern Spotlight retrieval: Which pattern is this, and which variable is the total-so-far? Variation axis — data and packaging: a numeric list and inline loop instead of a function.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 11: Award a Score Tier
Start with scores = [1000, 999, 499] and gold_count = 0. Loop over the scores. If a score is at least 1000, store "gold" in tier and add 1 to gold_count; elif it is at least 500, store "silver"; otherwise store "bronze". Print each score and tier in an f-string, then print the accumulated gold count.
Pattern Spotlight retrieval: Which pattern is this, and which variable holds the count-so-far? Variation axis — data: numeric scores and a threshold replace boolean answer results.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 12: Tidy the Champion Names
Start with raw_winners = [" grace hopper ", "ADA", " ada "] and an empty clean_winners list. Loop over the raw names and rebuild each one with .strip().upper(). If the cleaned name is already in clean_winners, print a repeated-name message; otherwise append it. At the end, print "Clean winners: " + str(clean_winners). Keep this name list separate from the score list.
Pattern Spotlight retrieval: Which pattern is being reused? Variation axis — cleaned strings: each raw name produces one cleaned name.
Real program
The real program reads how many names there are, then reads each name with input(...).
How this is checked: Checked by tests that run your code.
Exercise 13: Double the Qualifying Threshold
Start with scores = [640, 1500, 980], threshold = 10.0, and doublings = 0. Use max(scores) for the champion. Write a while loop that doubles the threshold and adds 1 to doublings until the threshold is greater than the champion score. Print the champion, the first qualifying decimal threshold, and the number of doublings in f-strings.
Pattern Spotlight: which pattern is this? which variable/condition says 'done yet?' Variation — data type and twist: a decimal threshold crosses a numeric boundary instead of matching a secret number or quitting on a string.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 14: Find the first over the bar, stop early
Start with board_scores = [720, 880, 1050, 940], qualifying_bar = 900, and first_qualifying = "not found". Scan the board scores one by one and compare each score with the qualifying bar. When the first score reaches or passes the bar, store it and use break to stop checking later scores. Print first_qualifying after the loop. Then try a bar of 2000 to check the not-found stand-in.
Pattern Spotlight retrieval: Which pattern checks in order and stops at the first match? Variation axis — data and twist: a list of numbers; keep the first qualifying item or the not-found stand-in.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 15: Champion by name
Start with names = ["Mina", "Leo", "Zoe", "Ari"] and scores = [1280, 1540, 1390, 1210]. Start best_name with the first name and best_score with the first score. Scan the positions with range(len(scores)). Whenever the current score is greater than best_score, update both best_score and best_name from that same position. After the loop, print the champion's name and score. Expected champion: Leo with 1540. Do not use max(); the explicit scan must remember which player owns the best score.
Real program
The real program reads how many players there are, then reads each name and score together with input(...).
How this is checked: Checked by tests that run your code.
Exercise 16: Keep only the qualifying scores
Start with scores = [720, 880, 1050, 940, 1310], threshold = 1000, and a NEW empty list named qualifying_scores. Loop over scores. Inside the loop, use a condition to check whether each score is at least the threshold, and append only passing scores to qualifying_scores. Print the new list after the loop. Expected result: [1050, 1310]. Do not use a list comprehension.
Pattern Spotlight retrieval: Which pattern builds a new list containing only items that pass a test? Variation axis — scores and threshold: filter arcade scores by a qualifying number.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: Checked by tests that run your code.
Exercise 17: Rookie by Name
Use the parallel lists names = ["Mina", "Leo", "Zoe", "Ari"] and scores = [720, 880, 650, 940] to find the lowest score, keeping both the rookie's name and score in rookie_name and rookie_score as you scan; do not just call min() on the scores and stop there. Worked example: the lowest score is 650, belonging to "Zoe", so rookie_name = "Zoe" and rookie_score = 650. Start rookie_name/rookie_score from the first name and score (never 0, or 0 always wins).
Real program
The real program reads how many players there are, then reads each name and score together with input(...).
How this is checked: Checked by tests that run your code.
Exercise 18: Best and Worst in One Pass
For scores = [720, 880, 1050, 940], use a single loop over the list to track both the highest and lowest scores seen so far. Worked example: best = 1050 and worst = 720.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 19: Average of the Passers
For scores = [600, 800, 1000, 900, 700] and a pass mark of 800, count the scores that are at least 800 and find their average using a running total divided by the count; if there are no passers, report 0 instead of dividing by zero. Worked example: the 3 passers are 800, 1000, and 900, so the average is 900.0.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 20: What Place Would I Be?
For scores = [1500, 1200, 990, 850] and my_score = 1000, count how many scores are strictly greater than my_score, then set the place to that count plus 1. Worked example: two scores, 1500 and 1200, are greater than 1000, so place = 3.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: Checked by tests that run your code.
Exercise 21: Scores That Fit the Wait Budget
For waiting = [300, 450, 275, 600] and a budget of 1000, check before adding each wait: add it only if the new total would stay at or under the budget, otherwise stop entirely, then report how many waits fit and the final total used. Worked example: 300 fits for a total of 300, then 450 fits for 750, but 275 would make 1025, so stop with 2 waits fitting for a total of 750; this check-before-adding version never exceeds the budget.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Exercise 22: Waits Until the Budget Tips
For waiting = [300, 450, 275, 600] and a budget of 1000, add each wait first and then check the total, stopping as soon as it goes strictly above the budget; report how many waits were added including the one that tipped it over, the tipping total, and the tipping wait. Worked example: adding 300 gives 300, adding 450 gives 750, and adding 275 gives 1025, which is over 1000, so stop with 3 waits added, a tipping total of 1025, and the tipping wait 275; unlike Exercise 21, this add-then-check version stops right after exceeding the budget.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: You check this one yourself, against the list below.
The site cannot check this one. Run your program, then tick each item below when your work does it.
Challenge
Challenge 1: Show the Top Three
Start with scores = [980, 1500, 720, 1310, 1100]. Sort the list top-first in place. Then print the top three scores by using indexes 0, 1, and 2.
Real program
The real program reads how many scores there are, then reads each score with int(input(...)).
How this is checked: Checked by tests that run your code.
Challenge 2: Merge a Second Score Board
Start with the unranked, arrival-order first board scores = [1200, 990, 1500, 840] and a second arcade's second_scores = [1310, 700, 1050, 1420]. Use one loop to append each score from second_scores to scores. Do not sort after each append. After the loop is completely finished, perform exactly one scores.sort(reverse=True). Only then print the merged board; do not display any Place labels before that one final sort. Do not use a nested loop.
Real program
The real program keeps the first board fixed, reads how many scores are on the second board, then reads those scores with int(input(...)).
How this is checked: Checked by tests that run your code.