Python nomor acak
# generate random integer values
from random import randint
value = randint(0, 10)
print(value)
Successful Stoat
# generate random integer values
from random import randint
value = randint(0, 10)
print(value)
import random
randomNumber = random.randint(1, 100)
print(randomNumber)
import random
a = random.randint(0,10)
print(random.randint(0,a))
# generate random integer values, Here the rand int will generate any number
# in integer between the given range.
from random import randint
value = randint(0, 10)
print(value)
import random
# Random number, 0 through 10, INCLUDING 10:
print(random.randint(0, 10))
#Random number, 0 through 10, NOT INCLUDING 10:
print(random.randrange(0, 10))
#Random choice from a list:
my_list = ["Apples", "Oranges", "Watermelon", "Pineapple", "Grapes"]
print(random.choice(my_list))
# Set a custom seed of 10 for random to work with:
random.seed(10)