0
How to write a python program to guess a number
Guessing a random number between 1 9
3 Respostas
+ 8
Hints:
1. Store input in a variable
2. make a random guess between 1-9
3. Compare your guess with input.
3.1 if input larger than guess reduce the value of your variable by a fixed(variable?) amount.
3.2 otherwise try to do inverse by increasing it.
4. (Write step 4)
+ 6
It would be great if you try it yourself first and link your code from playground in your post here.
+ 3
import random
difval=random.randrange(10)
print(difval )
Just import random module then use its randrange function to sepicify it's range. Each time when u run thies code it will generate a different number