Step 1: The Secret Number ๐ฒ
You're building Number Detective: the computer hides a number, you hunt it down with clues, and at the end you get ranked on how good a detective you are. ๐ต๏ธ
Everything starts with the computer picking a number you can't predict.
That's what the random module is for:
import random
roll = random.randint(1, 6) # a random whole number from 1 to 6
print(roll)
randint(1, 6) means "pick a whole number from 1 to 6" โ and both ends
count, so 1 and 6 can happen too.
Your mission
- Put
import randomat the very top - Make a variable
secretholdingrandom.randint(1, 50) - Print it โ for now you're allowed to spy on it! ๐
- Run your program 3 or 4 times and watch the number change
Your code
Press โถ Run to see what your code does!