AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Stop the crash

Week 13 · 1.8 Testing · 3 lessons
Answers are for parents and teachers.
1
Say whether each is a syntax error, a logic error or a run-time error: (a) print(25 / 0) (b) a missing closing bracket in a print line (c) a change calculation that uses + where it should use − (d) int("1o") typed by the user.
2
The user types 3, and then another time 1. What happens each time? Explain, and write a repaired program.
Python
1prices = [3, 8, 5]
2choice = int(input("Item number (1 to 3)? "))
3print("Price:", prices[choice])
3
A club asks for a username. It must be typed and have from 4 to 10 characters. Write the program in Python on paper, with a message for each problem.
4
Make a trace table with the columns water, days and Output. What does the program print? Does the loop end?
Python
1water = 1
2days = 0
3while water < 20:
4    water = water * 2
5    days = days + 1
6print(days)
5
Explain in one sentence each what a syntax error, a logic error and a run-time error are, and give your own example of each.