+ 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?

16th Oct 2018, 5:37 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
5 ответов
+ 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.
16th Oct 2018, 6:08 PM
Ahri Fox
Ahri Fox - avatar
+ 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)
17th Oct 2018, 7:20 AM
Ahri Fox
Ahri Fox - avatar
+ 3
I deleted the random.radiant(0,99) and nothing changed , i guess i need it only when i use number?🌀
17th Oct 2018, 6:59 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 3
Thank you for help. I am checking your codes for advanced tehniques. 😀
17th Oct 2018, 9:57 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
18th Oct 2018, 2:31 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar