Articles → Python → Random Functions In Python
Random Functions In Python
Random Functions
- choice
- shuffle
- randrange
Choice
import random
fruits = ["Apple", "Orange", "Banana", "Grapes", "Strawberry"]
print (random.choice(fruits))
Shuffle
import random
fruits = ["Apple", "Orange", "Banana", "Grapes", "Strawberry"]
print (fruits)
random.shuffle(fruits)
print (fruits)
Randrange
import random
print (random.randrange(1,10))