WEB PRACTICE W091Reading list tracker
Display reading progress for several books using a dictionary.
Reveal a hint
Count how many books have a True flag.
Reveal example code (after trying it yourself)
books = {'Code Club':True,'Robot Stories':False,'Data Detective':True}
completed = sum(books.values())
print(f'{completed}/{len(books)} finished')
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W092Shop loyalty summary
Calculate the final cost of a basket with a 5% loyalty discount.
Reveal a hint
Use sum, then multiply by 0.95.
Reveal example code (after trying it yourself)
products = {'notebook':3.25,'pen':1.40,'folder':2.10}
subtotal = sum(products.values())
loyalty_total = subtotal * 0.95
print(f'Total: £{loyalty_total:.2f}')
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W093Quiz results dashboard
Compute the average, highest and pass count for five scores.
Reveal a hint
Use sum, max and a comprehension.
Reveal example code (after trying it yourself)
scores = [8, 5, 10, 6, 4]
print('Average:', sum(scores)/len(scores))
print('Highest:', max(scores))
print('Passed:', sum(s>=6 for s in scores))
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W094Simple task manager
Store tasks with priorities and print high-priority tasks.
Reveal a hint
Keep each task in a dictionary.
Reveal example code (after trying it yourself)
tasks = [{'name':'Code','priority':'high'}, {'name':'Read','priority':'low'}, {'name':'Test','priority':'high'}]
for task in tasks:
if task['priority'] == 'high':
print('Important:', task['name'])
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W095Budget planner
Calculate whether spending exceeds a given weekly budget.
Reveal a hint
Use the difference between budget and spend.
Reveal example code (after trying it yourself)
budget = 50
spending = [12.50, 9.99, 14.25, 8.00]
remaining = budget - sum(spending)
print(f'Remaining: £{remaining:.2f}')
print('Within budget' if remaining >= 0 else 'Over budget')
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W096Revision flashcards
Select a flashcard from a dictionary and display its answer.
Reveal a hint
Iterate through a key-value pair.
Reveal example code (after trying it yourself)
flashcards = {'CPU':'Central Processing Unit','RAM':'Random Access Memory'}
for question, answer in flashcards.items():
print(question, '->', answer)
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W097Fitness summary
Compute the distance total and best day from a short list.
Reveal a hint
Use sum and max; each list entry is in kilometres.
Reveal example code (after trying it yourself)
distances = [2.4, 3.2, 4.1, 1.8, 3.9]
print('Total:', round(sum(distances), 1), 'km')
print('Longest:', max(distances), 'km')
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W098Library borrowing audit
Count how many sample borrowers have overdue books.
Reveal a hint
Use a list of dictionaries with an overdue key.
Reveal example code (after trying it yourself)
borrowers = [{'name':'Ada','overdue':False},{'name':'Ben','overdue':True},{'name':'Cara','overdue':True}]
print('Overdue borrowers:', [b['name'] for b in borrowers if b['overdue']])
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W099Mini text analyser
Count the unique words in a short sentence, ignoring case.
Reveal a hint
Split lowercased text and pass it to set().
Reveal example code (after trying it yourself)
text = 'Python code helps us learn code'
words = text.lower().split()
print('Unique words:', len(set(words)))
print('Total words:', len(words))
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.
WEB PRACTICE W100Project test report
Check a list of fictional function-test outcomes and print a summary.
Reveal a hint
Count True values and compare count with total tests.
Reveal example code (after trying it yourself)
tests = {'input':True,'calculation':True,'boundary':False,'output':True}
passing = sum(tests.values())
print(f'Tests passing: {passing}/{len(tests)}')
print('All passed' if passing == len(tests) else 'Review failed tests')
One possible solution. Try writing your own first.
Extension: Change the sample values and test at least two different cases.