- 
                Notifications
    
You must be signed in to change notification settings  - Fork 266
 
Mad Libs
        LeWiz24 edited this page Aug 27, 2024 
        ·
        2 revisions
      
    TIP102 Unit 1 Session 1 Standard (Click for link to problem statements)
- 💡 Difficulty: Easy
 - ⏰ Time to complete: 5 mins
 - 🛠️ Topics: Functions, String Formatting
 
Understand what the interviewer is asking for by using test cases and questions about the problem.
- 
Q: What does the function do with the
verbparameter?- A: The function inserts the 
verbparameter into a specific sentence and prints it. 
 - A: The function inserts the 
 - 
Q: How is the
verbparameter incorporated into the sentence?- A: The 
verbis placed in the sentence where<verb>is specified. 
 - A: The 
 - 
The function madlib() should accept a string parameter verb and print a specific sentence incorporating that verb.
 
HAPPY CASE
Input: "give up"
Output: I have one power. I never give up. - Batman
Input: "nap"
Output: I have one power. I never nap. - Batman
EDGE CASE
In the case of the madlib() function, there aren’t any traditional edge cases to consider, as the function simply prints a fixed string without any inputs or conditions that could vary the output. 
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Define a function that incorporates the parameter into a formatted string.
1. Define the function `madlib(verb)`.
2. Use an f-string to print the sentence with the verb included.
- Forgetting to use the parameter verb in the f-string.
 - Not using the correct syntax for f-strings.
 
Implement the code to solve the algorithm.
def madlib(verb):
    print(f"I have one power. I never {verb}. - Batman")