Random Generator
π©π Feature Card: Build a Random Generator
- Type: Feature
- Useful for: Creating fun, surprising results like band names, superpowers, stories, passwords, and more!
π§ What Is It?
A random generator is a program that mixes things up and surprises the user. You can use it to generate things like:
- πΈ Funny band names
- π¦Έ Superhero identities
- π Silly story titles
- π Random passwords
- π Magical spells or creature names
These projects are fun and creative, and they help you learn how to combine lists, random choices, and string output.
π§ͺ You Could Tryβ¦
π‘ Basic Band Name Generator
import random
word1 = ["Electric", "Spiky", "Wobbly", "Cosmic"]
word2 = ["Tigers", "Wizards", "Socks", "Bananas"]
name = f"{random.choice(word1)} {random.choice(word2)}"
print(f"Your band name is: {name}")
π£ Make It More Personal
Ask the user a question and use the answer in the result:
import random
word1 = input("Whatβs your favourite colour? ")
word2 = ["Banana", "Tiger", "Wizard", "Sock"]
print(f"Your superhero is the {word1} {random.choice(word2)}")
π’ Add Themes or Categories
import random
theme = input("Choose a theme (spooky, space): ")
if theme == "spooky":
word1 = ["Haunted", "Creepy", "Ghastly"]
word2 = ["Pumpkins", "Ghosts", "Bats"]
elif theme == "space":
word1 = ["Galactic", "Cosmic", "Starlit"]
word2 = ["Rockets", "Aliens", "Comets"]
else:
word1 = ["Mystery"]
word2 = ["Things"]
name = f"{random.choice(word1)} {random.choice(word2)}"
print(f"Your band name is: The {name}")
π§° Technique Cards (Practical Skills)
These practical technique cards can help take your understanding further:
- π Technique Card: Lists in Python
- π Technique Card: Random Choice from Lists
- π Technique Card: Strings and Integers
- π Technique Card: User Input
π§ Challenges
- Make a name generator with a theme the user picks
- Add a third word for more creative names
- Ask more questions to influence the result
- Make a generator that prints 3 results at once
- Build a password generator that uses random letters and numbers
- Create a madlib story generator
π― When to use this Feature
Project Examples | Why a Random Generator |
---|---|
Band Name Generator | Create Funny Random Band Names and More |