random random in python code example

Example 1: how to use random in python

import random
print(random.randint(3, 7)) #Prints a random number between 3 and 7
array = [cars, bananas, jet]
print(random.choice(array)) #Prints one of the values in the array at random

Example 2: random number pythob

import random
random.randint(a,b)

Example 3: python random

import random
print(random.randint(0,1))

Example 4: python randint

from random import randint
print(randint(1,2))

Example 5: generate random number python

import random
lower_limit = 0 # Can be anything
upper_limit = 100 # Again, can be anything
# Print it out
print(f"Here is a random number: {random.randint(lower_limit, upper_limit)}