Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Coding Word Problem in Script
- polargiant3
- New to Scratch
2 posts
Coding Word Problem in Script
I'm working on a lesson plan called “Interactive Word Problem Posters” from Makey Makey. The coding is partially done in the script but how do I know if the answer is right or wrong? Please see the link to my script below.
https://scratch.mit.edu/projects/199305873/#editor
Thank you!
Michelle Thomas
https://scratch.mit.edu/projects/199305873/#editor
Thank you!
Michelle Thomas
- DaEpikDude
- Scratcher
1000+ posts
Coding Word Problem in Script
Well, there are a few problems with your script that you can change:
1: To divide something by something, you can't just type “12/4” in the box.
So your code would look like:
Also, for future reference, when you have a problem with code you might want to put your topic in the Help with Scripts forum. I'll report this thread to be moved for you
1: To divide something by something, you can't just type “12/4” in the box.
<[12/4] =[3]>would check if “12/4” is the same as “3”, which it isn't. You need to use the divided by block, i.e.
<((12) / (4)) = [3]>Also, that would just check if 12 / 4 = 3 which would always return true. To use the ask block, you also use the block “answer” which is right next to the ask block.
So your code would look like:
if <(answer) = [3]> thenI also noticed that you can optimise your code: since it checks if the answer is correct, then constantly repeats if it's not, you can do this instead:
...
end
ask [question so and so] and wait
repeat until <(answer) = [the answer]> // if it's right in the first place this will never happen
ask [That's not right, try again] and wait
end
say [you did it yay congrendulates]
Also, for future reference, when you have a problem with code you might want to put your topic in the Help with Scripts forum. I'll report this thread to be moved for you
And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
- polargiant3
- New to Scratch
2 posts
Coding Word Problem in Script
Hello,
How do you make the program repeat until the student gets the problem right?
https://scratch.mit.edu/projects/199305873/#editor
Thank You!
Michelle Thomas
How do you make the program repeat until the student gets the problem right?
https://scratch.mit.edu/projects/199305873/#editor
Thank You!
Michelle Thomas
- DaEpikDude
- Scratcher
1000+ posts
Coding Word Problem in Script
Right now your program isn't actually using the student's answer, it's just checking if 12 / 4 is 3, which of course it is.
To fix this just replace the “12 / 4” block with the answer block (which is right next to ask and wait).
To fix this just replace the “12 / 4” block with the answer block (which is right next to ask and wait).
And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
- omega_red
- Scratcher
8 posts
Coding Word Problem in Script
Saying ‘repeat until 12/4=3’ is the same as saying ‘repeat until 1=1’, which will always be true, no matter what the answer. maybe try this :
repeat until <(answer) = [3]>
ask [whats 12/3?] and wait
end
Last edited by omega_red (Feb. 9, 2018 08:51:24)
- asivi
- Scratcher
1000+ posts
Coding Word Problem in Script
Saying ‘repeat until 12/4=3’ is the same as saying ‘repeat until 1=1’, which will always be true, no matter what the answer. maybe try this :repeat until <(answer) = [3]>
ask [whats 12/3?] and wait
end
4?
- deck26
- Scratcher
1000+ posts
Coding Word Problem in Script
Please don't spam or necropostwhen green flag clicked:)
- Discussion Forums
- » Help with Scripts
- » Coding Word Problem in Script