Module 9 – Build Simple AI Projects! 🛠️
intermediate25 XP
Guessing Game & Story Machine! 📖🎮
Build a funny AI fortune teller and a random story generator in Python
Guessing Game & Story Machine! 📖🎮
Project 1: The AI Fortune Teller 🔮
A magic 8-ball that uses AI-style responses!
Python
import random
def fortune_teller(question):
responses = [
# Positive
"🌟 The AI predicts: DEFINITELY YES! The stars align in your favour!",
"✅ My circuits say: Almost certainly! Go for it!",
"🚀 The probability matrix says: Yes, and it'll be AMAZING!",
"😊 My neural networks are 94.7% certain: YES!",
# Uncertain
"🤔 Hmm... My algorithms are confused. Try asking clearer?",
"⚖️ The data is mixed. Could go either way, honestly.",
"🌊 My prediction: It's uncertain. The future is hard to compute!",
# Negative
"😬 The AI hesitates... Maybe wait a bit?",
"❌ My calculations suggest: Not the best idea right now!",
"🔄 System says: Try again later. Current conditions unfavourable.",
]
print(f"\n🤖 Analysing your question...")
print(f"Processing 1,000,000 data points... 💭")
print(f"\n{random.choice(responses)}\n")
# Run it!
print("🔮 Welcome to the AI Fortune Teller 3000!")
print("Ask me ANY yes/no question...\n")
while True:
question = input("Your question: ")
if question.lower() in ["quit", "bye", "exit"]:
print("🤖 Goodbye! May your future be full of bugs... I mean, features! 🐛")
break
fortune_teller(question)Project 2: The Random Story Generator 📚
Python
import random
def generate_story():
characters = ["a confused robot", "a sleepy wizard", "a pizza-loving cat",
"a time-travelling student", "a dancing gorilla"]
locations = ["inside a video game", "on the moon", "in a Minecraft world",
"at a sushi restaurant", "in a school for superheroes"]
problems = ["forgot how to do maths", "accidentally became famous on TikTok",
"their pet started speaking Python", "fell asleep in a Zoom call",
"ate 47 chicken nuggets and gained flying powers"]
solutions = ["by asking Cody the AI for help", "by writing a Python program",
"by blaming their WiFi", "by explaining it was 'an AI glitch'",
"by finding a cheat code in real life"]
character = random.choice(characters)
location = random.choice(locations)
problem = problems[random.randint(0, len(problems)-1)]
solution = random.choice(solutions)
story = f"""
📖 ONCE UPON A TIME...
There was {character} who lived {location}.
One day, they {problem}.
"Oh no!" they cried. "This is catastrophic!"
But after much thinking (and 3 cups of hot chocolate ☕),
they solved the problem {solution}.
And they all lived happily ever after. THE END. 🎉
"""
return story
# Generate stories!
print("📚 The Random Story Generator 3000!")
while True:
input("Press ENTER for a new story (or Ctrl+C to quit)...")
print(generate_story())💡 What These Projects Teach
These silly projects use real AI concepts:
- Random selection = how AI generates varied responses
- Template + variable filling = how AI language models work
- Response libraries = like AI training data
- User input loops = how chatbots work
ChatGPT is essentially a much, much more sophisticated version of these ideas!
⌨️
Type it yourself
Don't just read it — type the example from above into the box, press Run ▶, and watch what happens. Typing it yourself is how it really sticks! Stuck? Tap Show example.
Python · Playground
Output
Press ▶ Run to see your code come to life…Quick check
01/2
The fortune teller program uses random.choice() — what does this do?