Person Class
You are asked to create a
Person
class that has four attributes: name
, age
, gender
, and address
. The class should also have a method display_info()
which when called, prints the person's details in a readable format.The class should accept 4 arguments:
- The person's name.
- The person's age.
- The person's gender (
M
for male,F
for female).
- The person's address.
The output of the
display_info()
method should print the information in the following format:
Name: {name}, Age: {age}, Gender: {gender}, Address: {address}
Input | Output |
p = Person('Anna', 34, 'F', '123 Fake St.'); p.display_info() | Name: Anna, Age: 34, Gender: F, Address: 123 Fake St. |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB