How do I make a random number in python?
ThePuzzlerThree

On repl.it, import Math does not work, so I can not use math.random to make a random number. What do I do to generate a number?

You are viewing a single comment. View All
Answered by UzayAnil [earned 5 cycles]
View Answer
DarshanRajpara

this:
import random
x = random.randrange(1,100)

First you import random. then use the function randrange to create the random number, with the first parameter being the lowest number it can generate, and the second being the highest.
Hope this helped you out!

UzayAnil

apparently, your supposed to do:
import random
x = random.randint(1, 100)
print(x) @DarshanRajpara

ThePuzzlerThree

@UzayAnil thank you it worked! I hope you will check out this project when it is finished!

jameshoward3

@ThePuzzlerThree if you dont want to import whole random lib, you could use
from random import randint

x = randint(1, 100)
print(x)