JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Gallery
Debug 3.4. Parse Input with starter code
Share
Explore
Gallery
Debug 3.4. Parse Input with starter code
Debug 3.4. Parse Input with starter code
The Task
Python Starter Code
Code Clips
Python Starter Code
Copy and paste the code below into your
main.py
file before you begin the task.
import
time
# blank line
print
(
'\n\n'
)
# ASKS the user to enter the name of Krispy Kreme doughnut
doughnutName
=
float
(
input
(
'Enter doughnut name: '
)
)
# ASKS the user to enter the description of the Krispy Kreme doughnut
description
=
int
(
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
=
int
(
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: '
+
kcal
)
print
(
'Collection: '
+
collection
)
print
(
'Cost: £'
+
cost
)
Gallery
Share
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
Ctrl
P
) instead.