This homework is really fun, because I need to create a game, so the user should guess which number the program did choose.
I didn’t know how to print/choose a random number, this website helped me out. The variable for the random number will be “x”
Alright, the range that I need is from 1 to 100. While proving the code, I’ll print the random number, but I’ll erase line 3 when I end up the homework.
Then I need the user to guess my number, so I enter an input. And of course I assign it a variable, “y”.
After that, we start with the “if” sentences.
As we want our user to guess, we need to give him/her some clues. If he/she typed a lower or higher number, the program should print which is the problem.
Up to here, the result is this:
Now I’ll say the user how many times he/she needed to guess the right number, and I’ll also comment line 3.
Aaand there we go… 😀 Here’s my code, you can download it if you need/want to.