TIP102 Unit 5 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.
- 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?
Player
class and correctly initialize the attributes.HAPPY CASE
Input: Instantiate Player with "Yoshi" as character and "Super Blooper" as kart
Output: Player's character is "Yoshi", kart is "Super Blooper", and items list is empty.
Explanation: We correctly initialize the Player object with the provided values and an empty items list.
EDGE CASE
Input: Instantiate Player with an empty string for character and kart
Output: Player's character is ", kart is ", and items list is empty.
Explanation: We check if the object initializes correctly with empty strings.
Match what this problem looks like to known categories of problems, e.g. Linked List or Dynamic Programming, and strategies or patterns in those categories.
For class instantiation problems, we want to consider the following approaches:
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Create an instance of the Player
class and initialize its attributes based on the input parameters.
1) Define a class `Player` with a constructor that takes `character` and `kart` as parameters.
2) Inside the constructor, set `self.character` to the character parameter.
3) Set `self.kart` to the kart parameter.
4) Initialize `self.items` as an empty list.
5) Instantiate `player_one` with "Yoshi" as the character and "Super Blooper" as the kart.
⚠️ Common Mistakes
self.items
as an empty list.self
keyword.Implement the code to solve the algorithm.
class Player():
def __init__(self, character, kart):
self.character = character
self.kart = kart
self.items = []
player_one = Player("Yoshi", "Super Blooper")
Review the code by running specific example(s) and recording values (watchlist) of your code's variables along the way.
Evaluate the performance of your algorithm and state any strong/weak or future potential work.