1# imports random
2import random
3# randint generates a random integar between the first parameter and the second
4print(random.randint(1, 100))
1import random
2
3# random number 1 to 100
4x = random.randrange(0, 99)
5x = x + 1
6print(x)
1#import random
2import random
3
4names = ['Harry', 'John', 'Smith', 'Larry']
5
6#print random name from names
7print(random.choice(names))
8
9#print random integer in a range of numbers
10print(random.randint(1, 100)
1# imports random
2import random
3# randint generates a random integar between the first parameter and the second
4print(random.randint(1, 100))
5# random generates a random real number in the interval [0, 1)
6print(random.random())
1from random import randint # Import randint from random
2print(randint(1,20)) # Gets random number from first parameter to the second
1# I know somebody else has made a similar thing from mine.
2# Just letting you know that I didn't mean to copy his idea for this code.
3# If you saw this, I recommend check the other answers out, too.
4# Hope you guys understand...
5from random import randint
6
7# Prints a random number in between 1 and 1000
8print(f"Here is a random number: {randint(1, 1000)}")
1import random
2language=['English','Chinese','Hindi','Arabic','Bengali','Portuguese','Russian','Turkish' ]
3choices=random.choices(language,k=10)
4print(choices)
5sample= random.sample(language,k=5)
6print(sample)