1
+ # Mad Libs Project: Tragic and Hilarious Stories
2
+
3
+ def get_input (prompt ):
4
+ """Function to get user input with a prompt."""
5
+ return input (prompt )
6
+
7
+ def create_tragic_story (elderly_woman_name , grandson_name ):
8
+ """Generate the tragic story using provided names."""
9
+ tragic_story_template = """
10
+ In a quiet hospital room, an elderly woman named {elderly_woman_name} lay in bed, her memories fading.
11
+ Every day, her grandson {grandson_name} visited, hoping to spark recognition.
12
+ One day, he brought a photo of their last vacation together, but she only stared blankly.
13
+ As he held her hand, he whispered, 'I love you,' knowing this might be their final moment together.
14
+ """
15
+
16
+ return tragic_story_template .format (
17
+ elderly_woman_name = elderly_woman_name ,
18
+ grandson_name = grandson_name
19
+ )
20
+
21
+ def create_hilarious_story (owner_name , cat_name , adjective , cat_action , dog_action , noun ):
22
+ """Generate the hilarious story using provided inputs."""
23
+ hilarious_story_template = """
24
+ One sunny afternoon, {owner_name} decided to train their cat {cat_name} to fetch.
25
+ Armed with a {adjective} toy, they threw it across the yard.
26
+ To their surprise, the cat {cat_action} instead of fetching!
27
+ The neighbor's dog {dog_action} in confusion as the cat proudly strutted back with a {noun} instead!
28
+ """
29
+
30
+ return hilarious_story_template .format (
31
+ owner_name = owner_name ,
32
+ cat_name = cat_name ,
33
+ adjective = adjective ,
34
+ cat_action = cat_action ,
35
+ dog_action = dog_action ,
36
+ noun = noun
37
+ )
38
+
39
+ def main ():
40
+ """Main function to run the Mad Libs project."""
41
+
42
+ # Gather user input for the tragic story
43
+ print ("Let's create a tragic story!" )
44
+ elderly_woman_name = get_input ("Enter the name of the elderly woman: " )
45
+ grandson_name = get_input ("Enter the name of the grandson: " )
46
+
47
+ # Generate and display the tragic story
48
+ tragic_story = create_tragic_story (elderly_woman_name , grandson_name )
49
+ print ("\n Here is your tragic Mad Libs story:" )
50
+ print (tragic_story )
51
+
52
+ # Gather user input for the hilarious story
53
+ print ("Now, let's create a hilarious story!" )
54
+ owner_name = get_input ("Enter the name of the cat owner: " )
55
+ cat_name = get_input ("Enter the name of the cat: " )
56
+ adjective = get_input ("Enter an adjective: " )
57
+ cat_action = get_input ("Enter a verb (what the cat does): " )
58
+ dog_action = get_input ("Enter a verb (what the dog does): " )
59
+ noun = get_input ("Enter a noun: " )
60
+
61
+ # Generate and display the hilarious story
62
+ hilarious_story = create_hilarious_story (owner_name , cat_name , adjective , cat_action , dog_action , noun )
63
+ print ("\n Here is your hilarious Mad Libs story:" )
64
+ print (hilarious_story )
65
+
66
+ # Entry point for the program
67
+ if __name__ == "__main__" :
68
+ main ()
0 commit comments