Answers for "python random tutorial"

18

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
Posted by: Guest on March-07-2020
3

python random

import random
print(random.randint(0,1))
Posted by: Guest on October-03-2020
1

which function to use in random module for a list in python

random.choice
Posted by: Guest on May-11-2020
-1

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"
Posted by: Guest on July-18-2020

Python Answers by Framework

Browse Popular Code Answers by Language