+ 5
I need help with "import random" in python.
I want to make some sort of "life simulator" or "How you will spend your next day". But for that i need to understand how to use the " import random" , for random choise of name , and things like that. Can someone explain how that module works?
5 Respuestas
+ 8
import random
random.randint(0,99)
# this generates a number between two numbers of your choosing
example=["you rob a bank","you explode"]
random.choice(example)
#chooses one from the list
#and that's really all you need to know for that sort of code. I used to be well known for this genre of code, maybe some of my codes could help for more advanced techniques. but those two functions are all you need to start.
+ 5
#yes only when you want to generate random numbers. remember, it can be between any two numbers, except float but there are ways to do that too if you look it up.
print("My power level is over %s!!!!"%random.randint(9000,999999999999)
+ 3
I deleted the random.radiant(0,99) and nothing changed , i guess i need it only when i use number?🌀
+ 3
Thank you for help. I am checking your codes for advanced tehniques. 😀