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
Python Starter Code
Copy and paste the code below into your
main.py
file before you begin the task.
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
(
'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'
)
mysteryNumber
=
answer
+
answer
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
=
mysteryNumber
/
answer
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
=
7
-
mysteryNumber
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 " + answer + " !!!!'
)
Below is a link to the starter task. You can right click
open on replit
to demo the answer to pupils and talk through the code.
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.