Python 3.4 - Random Module
Remember that most of these modules come pre-installed with your Python software. It is a part of the standard library of modules and functions.
There are many different attributes to the random module that can work with list and generate generic data or pull from databases.
https://docs.python.org/3/library/random.html?highlight=random#module-random
https://www.youtube.com/watch?v=KzqSDvzOFNA
There are many different attributes to the random module that can work with list and generate generic data or pull from databases.
import random print(random.random()) print(random.uniform(1, 200)) # this will give a random number between the two integers print(random.randint(1, 6)) # this will return a whole integer greetings = ['hello', 'piss off', 'sup bro'] name = ['Nick', 'Matt', 'Dustin', 'Andrew'] last_names = ['Fassnacht', 'Krieger', 'Williams', 'Heinrich'] state = ['Arizona', 'California', 'Utah', 'Oregon'] print(random.choice(greetings)) print(random.choices(greetings, k=5)) # this will give 5 random choices print(random.choices(greetings, weights= [18, 18, 2], k=25)) # this will give 5 random choices deck = list(range(1, 53)) print(random.sample(deck, len(deck))) hand = random.sample(deck, k=5) print(hand) for num in range(100): greeting = random.choice(greetings) first = random.choice(name) last = random.choice(last_names) phone = f'{random.randint(100, 999)}-555-{random.randint(1000, 9999)}' states = random.choice(state) email = first.lower() + last.lower() + 'bogusemail@gmail.com' print(f'{greeting} {first} {last}\n{phone}\n{states}\n{email}')
https://docs.python.org/3/library/random.html?highlight=random#module-random
https://www.youtube.com/watch?v=KzqSDvzOFNA
Comments