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 with AI-style answers! random.choice() picks one item from a list, so you get a different answer each time you press Run.
import random
responses = [
"The AI predicts: DEFINITELY YES!",
"My circuits say: almost certainly!",
"Hmm... my algorithms are confused. Ask again?",
"The data is mixed. Could go either way!",
"My calculations say: not right now!",
]
questions = ["Will I win my soccer game?", "Will it snow tomorrow?", "Is pizza the best food?"]
for question in questions:
print("You ask:", question)
print("Fortune Teller:", random.choice(responses))
print()๐ก๐ง This isn't real prediction: it's just random! Real AI forecasts (like weather apps) look at data to make a smart guess. That's the big difference.
Project 2: The Story Machine ๐
AI writing tools fill in templates with words that fit. Let's make a silly version:
import random
characters = ["a confused robot", "a sleepy wizard", "a pizza-loving cat", "a brave honeybee"]
places = ["on the moon", "inside a video game", "at the bottom of the ocean", "on a busy farm"]
problems = ["lost their homework", "accidentally became famous", "started speaking Python"]
for story_number in range(1, 3):
print("Story", story_number)
print("Once upon a time,", random.choice(characters), "lived", random.choice(places) + ".")
print("One day, they", random.choice(problems) + "!")
print("They fixed it with a little help from AI. THE END.")
print()Press Run again and again: new stories every time! ๐ฒ
๐ก What these projects teach
- Random choice = how AI tools can give varied answers
- Templates + fill-in words = a simple version of how AI writes text
- Word lists = like a (tiny!) set of training data
Tools like ChatGPT are far more advanced, but they also build text piece by piece, choosing words that fit.
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.
Press โถ Run to see your code come to lifeโฆ