diff --git a/boxes.py b/boxes.py new file mode 100644 index 0000000..8ed5aee --- /dev/null +++ b/boxes.py @@ -0,0 +1,32 @@ +# BOXES +# +# Do NOT run this yet! +# First, guess what each program prints. Write your guesses on your paper. +# Then run it and check. + + +print("--- Program 1 ---") +pet = "cat" +print(pet) + + +print("--- Program 2 ---") +pet = "cat" +print("pet") + + +print("--- Program 3 ---") +pet = "cat" +pet = "dog" +print(pet) + + +print("--- Program 4 ---") +x = 5 +x = 7 +print(x) + + +print("--- Program 5 ---") +name = "Sam" +print("Hi, Sam " + name) diff --git a/madlibs_bear.py b/madlibs_bear.py new file mode 100644 index 0000000..fe078aa --- /dev/null +++ b/madlibs_bear.py @@ -0,0 +1,30 @@ +# MAD LIBS — Bear +# +# You write the questions AND the story. +# +# A box (variable) is made like this: +# name = input("Type a name: ") +# +# A story line uses boxes like this: +# print(f"One day, {name} went to the store.") +# +# Run it with the play button ▶ (top right). + + +# 1. Make at least 5 boxes. Ask for things like an animal, a food, +# a place, a silly word, a number. + + + +# 2. Write your story. At least 4 lines. Use every box at least once. +# Use one box two times. + +print() + + +print("THE END") + + +# BONUS 1: Ask for a number with int(input(...)). +# Do some maths with it inside the story, like {number * 100}. +# BONUS 2: Make the story ask a question in the middle, then keep going. diff --git a/madlibs_fox.py b/madlibs_fox.py new file mode 100644 index 0000000..bea9464 --- /dev/null +++ b/madlibs_fox.py @@ -0,0 +1,34 @@ +# MAD LIBS — Fox +# +# The story is at the bottom. It is already written. +# The story needs words. Each word goes in a box (a variable). +# +# 3 boxes are done for you. 2 are not. +# Find the ____ lines and finish them. Copy the ones that are done. +# If you see NameError: name '____' you missed a blank. +# +# Run it with the play button ▶ (top right). + + +name = input("Type a name: ") +animal = input("Type an animal: ") +food = input("Type a food: ") + +place = ____ # Ask for a place. Copy a line above and change it. +silly_word = ____ # Ask for a silly word. + + +# ----- THE STORY ----- +# The f means: fill in the boxes. +# {animal} means: open the box called animal and put its word here. + +print() +print(f"One day, {name} found a giant {animal} in the {place}.") +print(f"The {animal} was eating {food}.") +print(f"It looked up and yelled, \"{silly_word}!\"") +print(f"So {name} shared the {food}, and they became best friends.") +print("THE END") + + +# BONUS 1: Add one more line to the story. Use one of your boxes in it. +# BONUS 2: Make a new box called color. Use it in the story. diff --git a/madlibs_owl.py b/madlibs_owl.py new file mode 100644 index 0000000..03c1d7c --- /dev/null +++ b/madlibs_owl.py @@ -0,0 +1,44 @@ +# MAD LIBS — Owl +# +# The story is at the bottom. It is already written. +# It needs 5 boxes (variables). You make them. +# +# Here is how one box is made: +# +# name = input("Type a name: ") +# +# Run it with the play button ▶ (top right). + + +# 1. Make a box called name. Ask for a name. +name = input("Type a name: ") + +# 2. Make a box called animal. Ask for an animal. + + +# 3. Make a box called food. Ask for a food. + + +# 4. Make a box called place. Ask for a place. + + +# 5. Make a box called silly_word. Ask for a silly word. + + + +# ----- THE STORY ----- +# The f means: fill in the boxes. +# {animal} means: open the box called animal and put its word here. + +print() +print(f"One day, {name} found a giant {animal} in the {place}.") +print(f"The {animal} was eating {food}.") +print(f"It looked up and yelled, \"{silly_word}!\"") +print(f"So {name} shared the {food}, and they became best friends.") +print("THE END") + + +# BONUS 1: Add two more lines to the story. Use your boxes. +# BONUS 2: Ask for a number, like this: +# number = int(input("Type a number: ")) +# Then use {number * 2} in the story. What happens?