0
how to randomize in python
I canot seem to get the randomizing right, my program seems to alwas print the same thing. I cant seem to get multipul in puts either.
12 Respostas
+ 8
Different results at each execution ;)
https://code.sololearn.com/czxJakKjcTHu/?ref=app
+ 8
@Ace You can specify random.seed(n), which, when omitted or None, uses the system clock each time. So I assume its default value is None.
+ 1
Click on (Code Playground) -> (New Code) -> choose Python, write your code, save it then click the share symbol, get the link and post it here.
+ 1
Hi! You can use the random module. If you want to get a random integer, you can do something like this;
import random
x = random.randint(number,throughnumber)
0
Show us your code and we might be able to help you.
0
print ("If I get 200 likes, I will make another 20-30 days on the program\n")
print ("This is my first program in python so lets see how it goes!\n")
print ("Day one:")
print ("you start a quest to go and kill a dragon")
print ("your stats are: 60 life, 0 xp, weapons: 20 darts(5damage each), blow dart gun\n")
if print ("Day two:"):
print ("You meet someone and Her name is Queen of maces\n")
else:
if print ("You reach Castle of great Motes"):
print ("In it you find 3 normal darts\n")
print ("your stats are now: 60 life, 0 xp, weapons: 23 darts(5damage each), blow dart gun\n")
else:
print ("In it you find 1 poison dart")
print ("your stats are: 20 darts(5damage each), 1 pioson dart(15damage), weapons: blow dart gun\n")
print ("Day three:")
print ("You start on into a field")
print ("In the field you meet a boar witch you battle")
print ("the boars stats: 15 life, 0 xp, weapons: tuscks(5 power)")
if print ("the boar uses tusck attack"):
print ("you get -5 life")
else:
print ("the attack misses")
if print ("You shoot a pioson dart"):
print ("the attack misses")
else:
print ("the boar gets -15 life and dies")
print ("You win the battle!(you get +2 xp!)")
print ("Your stats are: 60 life, 2 xp, weapons: 20 darts(5damage each), blow dart gun\n")
print ("Day four:")
if print ("you hear somone yell HELP"):
print ("you go to help, but you cant find the person in trouble")
else:
print ("you save the viliger that crashed there cart, they give you a knife")
print ("you get 2 xp!")
print ("your stats are: 60 life, 4 xp, weapons: 20 darts(5damage each), blow dart gun, knife(20damage)\n")
0
Here it is
0
Bruh there's no randomness here ._.
Besides, "if print("Day one")" is obviously an invalid syntax.
0
Run the program, it's all good syntax
0
Create a code on SoloLearn and put the link here.
0
How
0
@Ace
The default seed which comes with the library, ofc.