Gallery
Solution Debug 3.4. Parse Input
Share
Explore
Solution Debug 3.4. Parse Input

icon picker
Solution

At the right hand side is the the task, starter code and code clips that pupils got.
Below is a link to the solution. You can right click open on replit to demo the answer to pupils and talk through the code.
Incase it doesn’t load above here is the link
import time

# blank line
print('\n\n')
# ASKS the user to enter the name of Krispy Kreme doughnut
doughnutName = input('Enter doughnut name: ')

# ASKS the user to enter the description of the Krispy Kreme doughnut
description = input('Enter doughnut description: ')

# ASKS the user to enter the kcal of the Krispy Kreme doughnut
kcal = int(input('Enter kcal: '))

# ASKS the user to enter if collection is available for Kirspy Kreme doughnut
collection = bool(int(input('For collection? (enter 1-True or 0-False): ')))

# ASKS the user to enter cost of Kirspy Kreme doughnut
cost = float(input('Enter cost: £'))
# blank line
print('\n\n')
# DISPLAY processing doughnut message
print('Uploading doughnut....')

# pauses program for 3 seconds
time.sleep(3)
# clears screen
print('\033[H\033[2J')

# blank line
print('\n\n')
# DISPLAY Krispy Kreme title
print("Krispy Kreme Doughnut")
print("--------------------")
# DISPLAY user output
print('Doughnut name: ' + doughnutName)
print('Doughnut description: ' + description)
print('kcal: ' + str(kcal))
print('Collection: ' + str(collection))
print('Cost: £' + str(cost))

Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.