JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Gallery
Solution Debug 4.2. Mind Reader
Share
Explore
Gallery
Solution Debug 4.2. Mind Reader
Solution Debug 4.2. Mind Reader
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-42-Mind-reader?v=1
solution
import
time
# prints a blank line
print
(
'\n'
)
print
(
'I am going to read your mind!'
)
# prints a blank line
print
(
'\n'
)
# ask user for a number 1-9
mysteryNumber
=
int
(
input
(
'Think of a mystery number 1-9, type it in: '
)
)
# prints a blank line
print
(
'\n'
)
# Tell them to start the answer by adding the mystery number to itself.
print
(
'Add your number to itself'
)
answer
=
mysteryNumber
+
mysteryNumber
time
.
sleep
(
5
)
print
(
' . . still reading your mind . .\n\n'
)
time
.
sleep
(
5
)
# Ask them to multiply the new number by 5.
print
(
'Multiply the new number by 5'
)
answer
=
answer
*
5
time
.
sleep
(
5
)
print
(
' . . still reading your mind . .\n\n'
)
time
.
sleep
(
5
)
# Tell them divide their current number by their original number.
print
(
'Divide the current number by the original number'
)
answer
=
answer
/
mysteryNumber
time
.
sleep
(
5
)
print
(
' . . still reading your mind . .\n\n'
)
time
.
sleep
(
5
)
# Now say subtract 7 from their current number.
print
(
'Subtract 7 from the current number'
)
answer
=
answer
-
7
time
.
sleep
(
5
)
print
(
' . . still reading your mind . .\n\n'
)
time
.
sleep
(
5
)
# prints a blank line
print
(
'\n'
)
# display addition sum and answer
print
(
'The answer should be '
+
str
(
answer
)
+
' !!!!'
)
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.