RESOURCES:
Class slides: https://docs.google.com/presentation/d/11UieHJcWcYvJy7hVcSUFgwp2mINhqcw71oD3T8qy-5s/edit?usp=sharing
Example code: https://replit.com/@ShravyaS/IntroToPython-5
(Notes included in example code.)
HOMEWORK:
For this project, please build a mad-lib generator. Mad-libs are stories where the user fills out some words, which are inserted into a (sort of) template. For this project, please allow users to choose between (at least) 3 story templates. Think of using .title() and .capitalize() "Enter the number 1 if you want the story about cheeseburgers, the number 2 if you want the story about Romeo and Juliet, and 3 if …"
https://madtakes.com/libs/152.html (example)
Write your answer as a comment, and we’ll post the solution by next class. See you then!
Note: VIP students, please contact us (Eric and me) about office hours!
print('If you want to hear the Madlib about Bob and his food, type 1 below. If you want the story about someone\'s birthday, type 2 below. If you want the Minecraft story, type 3 below.') story = int(input()) if story == 1: print('food') food = input() print('verb') action1 = input() print('random restaurant name') random_restaurant_name = input() print('verb') what_he_did_with_food = input() print('emotion') after_eating = input() print(f'Once upon a time, there was a time where there was a guy named Bob, and he wanted a {food}. "I\'m hungry," said Bob, "I want a {food}." So Bob {action1} over to his favorite restaurant: {random_restaurant_name}, to get his {food}. It took him forever to get his {food} because the drive-through line was so long. "Finally, one {food} please!" said Bob. "Coming right up sir." said the empolyee. He brought up Bob\'s {food} and yelled, "Next!". Bob {action1} home and {what_he_did_with_food} his {food}. "Wow!" he exclaimed, "I feel so {after_eating} after eating that {food}!"') if story == 2: print('boy name') name = input() print('age(PLEASE type your number like third, or fourth, or like first)') age = input() print('object') gift = input() print('random shop name') random_shop_name = input() print('verb') action2 = input() print('verb with an -ing') action3 = input() print(f'It was {name}\'s {age} birthday, and he wanted a {gift}. "I want a {gift}", he exclaimed. So {name} and his mom {action2} to {random_shop_name}, but couldn\'t find a(n) {gift}. so {name} pouted when he got home. it turns out {name}\'s dad bought his {gift} for him, so {name} didn\'t need to buy it. so {name} thanked his dad and un-wrapped the wrapping paper. he got out his new {gift} and started {action3} with it.') if g == 3: print('random name, like noob123') name = input() print('enemy name') e_name = input() print('verb ending with -ed') verbed1 = input() print('object') thing = input() print('minecraft spell or verb ending with -ed') verbed2 = input() print(f'Once in the minecraft world, there lived a hero named {name}. {name} was a mediocre hero and protected the villagers. Then one day, {e_name}, the enraged warrior, blasted the village wall with a TNT blaster. {e_name} yelled, "I challenge the great warrior, {name}!!!" {name} came forth, and was suddenly knocked unconscious. When {name} woke up, {name} was in a giant arena with lots of people around {name} and {e_name}, and none of the people were any of {name}\'s people. "Which weapon do you choose?!?" {name} chose an enchanted bow and arrow. {e_name} chose an netherite sword with fire aspect 2. It also wasn\'t fair for {name} because {name} didn\'t have armor but {e_name} did. The referee shouted, "GOOOOO!!!" {e_name} {verbed1} after {name}, and {name} ran from {e_name}, but {name} mustered all the courage {name} could and was about to shoot with the bow and arrow, when {name} tripped on a(n) {thing}, and shot the arrow high into the air...and into a chink in {e_name}\'s armor, and it turn\'s out the bow and arrow had {verbed2}, so {e_name} lost and died and respawned outside the ring."1,2,3! {name} wins!" the referee yelled. So {e_name} had to suffer the consequence for losing, and {name} received the trophy and went back home. The end.')