How To Use Random In Python3

1.How To Use Simple Random in Python3.

import random as rand

a = 10
b = 100
print('print numbers [', a, ', ', b, ') :', rand.randint(a,b))

start = 1
stop = 12
step = 2
print('print one number from the sequence :',rand.randrange(start, stop, step))

2.How To Use Random Special Functions in Python3.

import random as rand

print('Random number :',rand.random())
print('Uniform Distribution Value :',rand.uniform(1, 50))
print('Gaussian Values:',rand.gauss(0, 1))
print('Exponential Distribution Values:',rand.expovariate(1/10))

3.How To Retrieve Random Values Within Range in Python3.

import random

random.seed(10)#This Line is meant For Setting Maximum Limit

print('random Value = ', random.random())
print('random int Value Within Range = ', random.randint(1, 100))



4.How To Retrieve Random Values Within Specified Data Range in Python3.

import random as rand
string = "kkar technologies"
l = [11, 12, 13, 14, 101, 151]
print('Single character:',rand.choice(string))
print('random number :', rand.choice(l))
print('random string of length 4 chars:',rand.sample(string, 4))
print('random string of length 4 values :',rand.sample(l, 4))
rand.shuffle(l)
print('shuffled list values:', l)