JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Gallery
Solution Debug 4.4. Money-Off
Share
Explore
Gallery
Solution Debug 4.4. Money-Off
Solution Debug 4.4. Money-Off
Solution
The Task
Python Starter Code
Code Clips
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.
https://replit.com/@STACSSupport/Teachers-Debug-44-Money-off?v=1
solution
# prints a blank line
print
(
'\n\n'
)
# get original price
originalPrice
=
int
(
input
(
'Please enter the original price: '
)
)
# get sale price
salePrice
=
int
(
input
(
'Please enter the sale price: '
)
)
# calculate money saved
saving
=
originalPrice
-
salePrice
# prints a blank line
print
(
'\n\n'
)
# display results
print
(
'Super Sale!'
)
print
(
'This item used to cost £'
+
str
(
originalPrice
)
)
print
(
'Now available at £'
+
str
(
salePrice
)
)
print
(
'You save £'
+
str
(
saving
)
)
# prints a blank line
print
(
'\n\n'
)
original
# prints a blank line
print
(
'\n\n'
)
# get original price
originalPrice
=
int
(
input
(
'Please enter the original price: '
)
)
# get money off
saving
=
int
(
input
(
'Please enter the sale price: '
)
)
# calculate money saved
saving
=
salePrice
-
originalPrice
# prints a blank line
print
(
'\n\n'
)
# display results
print
(
'Super Sale!'
)
print
(
'This item used to cost £'
+
originalPrice
)
print
(
'Now available at £'
+
saving
)
print
(
'You save £'
+
salePrice
)
# prints a blank line
print
(
'\n\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.