JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Gallery
Debug 5.3. Baggage Check with starter code
Share
Explore
Gallery
Debug 5.3. Baggage Check with starter code
Debug 5.3. Baggage Check 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.
# print out a blank line
print
(
'\n'
)
# ask the user to enter weight of first bag
baggage1
=
int
(
input
(
'Please enter the weight of first bag (kg): '
)
)
# print out a blank line
print
(
'\n'
)
# ask the user to enter weight of second bag
baggage2
=
int
(
input
(
'Please enter the weight of second bag (kg): '
)
)
# work out the total
totalBaggage
=
baggage1
+
baggage2
;
# checks the user guess
# if it is the same as the computer number, display well done
# anything else display sorry message.
if
totalBaggage
<
baggageLimit
print
(
'That is OK '
+
str
(
totalBaggage
)
+
' is under '
+
str
(
baggageLimit
)
+
' Kgs. Thanks! '
)
else
print
(
'Sorry '
+
str
(
totalBaggage
)
+
' is over '
+
str
(
baggageLimit
)
+
' Kgs. You can pay extra though.'
)
# print out a blank line
print
(
'\n'
)
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.