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.

31st Oct 2017, 8:30 PM
Joseph Fisher
Joseph Fisher  - avatar
14 ответов
+ 8
Different results at each execution ;) https://code.sololearn.com/czxJakKjcTHu/?ref=app
31st Oct 2017, 9:30 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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.
1st Nov 2017, 6:41 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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.
31st Oct 2017, 9:03 PM
Witty Phantom
Witty Phantom - avatar
+ 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)
25th Nov 2017, 5:49 AM
Brian Baker
Brian Baker - avatar
0
Show us your code and we might be able to help you.
31st Oct 2017, 8:51 PM
Witty Phantom
Witty Phantom - avatar
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")
31st Oct 2017, 8:52 PM
Joseph Fisher
Joseph Fisher  - avatar
0
Here it is
31st Oct 2017, 8:52 PM
Joseph Fisher
Joseph Fisher  - avatar
0
Bruh there's no randomness here ._. Besides, "if print("Day one")" is obviously an invalid syntax.
31st Oct 2017, 8:58 PM
Witty Phantom
Witty Phantom - avatar
0
Run the program, it's all good syntax
31st Oct 2017, 9:00 PM
Joseph Fisher
Joseph Fisher  - avatar
0
Create a code on SoloLearn and put the link here.
31st Oct 2017, 9:01 PM
Witty Phantom
Witty Phantom - avatar
0
How
31st Oct 2017, 9:02 PM
Joseph Fisher
Joseph Fisher  - avatar
0
@Ace The default seed which comes with the library, ofc.
31st Oct 2017, 10:01 PM
Witty Phantom
Witty Phantom - avatar