-
Notifications
You must be signed in to change notification settings - Fork 255
Greeting
Raymond Chen edited this page Aug 1, 2024
·
7 revisions
TIP102 Unit 1 Session 1 Standard (Click for link to problem statements)
- 💡 Difficulty: Easy
- ⏰ Time to complete: 5 mins
- 🛠️ Topics: Functions, Strings, Paramters
Understand what the interviewer is asking for by using test cases and questions about the problem.
- Established a set (2-3) of test cases to verify their own solution later.
- Established a set (1-2) of edge cases to verify their solution handles complexities.
- Have fully understood the problem and have no clarifying questions.
- Have you verified any Time/Space Constraints for this problem?
- 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.
- Incorrectly formatting the string (ensure it matches exactly).
- Forgetting to pass the parameter to the function.
Implement the code to solve the algorithm.
def greeting(name):
print(f"Welcome to The Hundred Acre Wood {name}! My name is Christopher Robin.")