TIP102 Unit 1 Session 1 Standard (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
Q: What should the function greeting()
do?
name
and print a specific greeting message incorporating the given name
.Q: What should the output look like?
"Welcome to The Hundred Acre Wood <name>! My name is Christopher Robin."
Q: Are there any constraints on the input?
The function greeting()
should take a single parameter, name, and print a specific greeting message that includes the provided name.
HAPPY CASE
Input: "Michael"
Expected Output: Welcome to The Hundred Acre Wood Michael! My name is Christopher Robin.
Input: "Winnie the Pooh"
Expected Output: Welcome to The Hundred Acre Wood Winnie the Pooh! My name is Christopher Robin.
EDGE CASE
Input: " (empty string)
Expected Output: Welcome to The Hundred Acre Wood ! My name is Christopher Robin.
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Define a function that takes a parameter and prints a formatted string using that parameter.
1. Define the function `greeting(name)`.
2. Use the `print()` function to display the string "Welcome to The Hundred Acre Wood {name}! My name is Christopher Robin." using the provided name.
⚠️ Common Mistakes
Implement the code to solve the algorithm.
def greeting(name):
print(f"Welcome to The Hundred Acre Wood {name}! My name is Christopher Robin.")