Summary
Practice overriding a base class method to change behavior in a subclass.
Problem statement
Create a Person class with first_name and last_name attributes and a method full_name() that returns the name in the format "{first_name} {last_name}". Then create a FormalPerson subclass that overrides full_name() to return "{last_name}, {first_name}". Fill in the starter code. The tests will instantiate these classes and call full_name().
Task
Implement a Person base class and a FormalPerson subclass that overrides full_name().
Examples
Formal name
Input
FormalPerson('Alan','Turing').full_name()
Output
Turing, Alan
Explanation
FormalPerson overrides full_name to return last name first followed by a comma and the first name.
Input format
Instantiate Person or FormalPerson with two string arguments: first_name and last_name, then call full_name().
Output format
full_name() returns a single string. The harness compares string outputs.
Constraints
- first_name and last_name are strings (may be empty or contain hyphens/spaces). - Do not print from methods; return strings.
Samples
Sample input 0
Person('Ada','Lovelace').full_name()
Sample output 0
Ada Lovelace
Explanation 0
Person.full_name returns first and last name separated by a space.
AI assistant
Ask me anything!
Need help? I can explain the core idea behind this problem, review your current code, and give targeted hints. Use “Teach Theory” for the concept, “Get AI hint” for a quick scaffold nudge, or ask a specific question below.
Chat history is temporary and will not be saved.
Free preview includes 1 Teach Theory response and 1 AI hint on each of the first 3 lessons in this module.