Write a Python program that calculates an estimate of the braking distance in metres for a new model of go-kart that is travelling between 10 and 50 kilometres per hour (kph) - AQA - GCSE Computer Science - Question 18 - 2021 - Paper 1
Question 18
Write a Python program that calculates an estimate of the braking distance in metres for a new model of go-kart that is travelling between 10 and 50 kilometres per h... show full transcript
Worked Solution & Example Answer:Write a Python program that calculates an estimate of the braking distance in metres for a new model of go-kart that is travelling between 10 and 50 kilometres per hour (kph) - AQA - GCSE Computer Science - Question 18 - 2021 - Paper 1
Step 1
keep asking the user to enter a speed for the go-kart until they enter a speed that is between 10 and 50 (inclusive)
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
speed = 0
while speed < 10 or speed > 50:
speed = float(input('Enter the speed of the go-kart (10-50 kph): '))
Step 2
calculate the braking distance in metres by dividing the speed by 5
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
braking_distance = speed / 5
Step 3
ask the user if the ground is wet
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
is_wet = input('Is the ground wet? (yes/no): ').lower()
Step 4
if the ground is wet, multiply the braking distance by 1.5
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
if is_wet == 'yes':
braking_distance *= 1.5
Step 5
output the final calculated braking distance
97%
117 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
print(f'The calculated braking distance is: {braking_distance:.2f} metres')