random statement for python code example

Example 1: python random

# imports random
import random
# randint generates a random integar between the first parameter and the second
print(random.randint(1, 100))

Example 2: python random

# imports random
import random
# randint generates a random integar between the first parameter and the second
print(random.randint(1, 100))
# random generates a random real number in the interval [0, 1)
print(random.random())

Example 3: which function to use in random module for a list in python

random.choice

Example 4: import os from random import randint

import os
from random import randint
def amazon_gc():
os.system("clear")
print("Amazon giftcard generator")
print("Stop this with ctrl+c")
print("Starting generating giftcards........")
try:
while 1 == 10:
char = [0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','V','W','X','Y','Z']
giftcard = (random.choice(char),random.choice(char),random.choice(char),
random.choice(char),random.choice(char),random.choice(char),
random.choice(char),random.choice(char),random.choice(char),
random.choice(char),random.choice(char),random.choice(char),
random.choice(char),random.choice(char),random.choice(char))
h = (''.join(map(str, giftcard[0:4])))
u = (''.join(map(str, giftcard[4:10])))
n = (''.join(map(str, giftcard[10:])))
print("==================================")
print("Amazon giftcard: ")
d = (h+'-'+u+'-'+n)
print(h+'-'+u+'-'+n)
print("==================================")
time.sleep(5)
except KeyboardInterrupt as e:
print("bye"