I am trying to find out what is the problem/error from my code, how to do this for used-defined? (Expected method ‘get_name’ to be defined as: def get_name(self): … this is my code so far:
from datetime import date
class Person:
def __init__(self, name, height, birthdate):
# Set the name, height and birthdate of the
# newly created Person object to the argument
# objects.
# - name is a str
# - height is an int object in centimetres
# - birthdate is a date object from the
# module datetime
self.name = name
self.height = height
self.birthdate = birthdate
def get_name(self):
# Return the name of the person as a str.
return self.name
def get_height(self):
# Return the hight of the person in cm as an
# int.
return self.height
def get_age(self):
# Return the age of the person in years.
birthdate = self.birthdate
today = date.today()
subyear = 0
if today.month < birthdate.month or (today.month == birthdate.day and today.day <= birthdate.day):
subyear = 1
self.age = (today.year - (birthdate.year + subyear))
return self.age
def get_description(self):
# Return a string object of the form: Name is
# N cm high and is M years old, where N and M
# are integers:
return self.name + ' is ' + str(self.height) + ' cm high and is ' + str(get_age(self)) + ' years old'
birthdate = date(1976, 8, 14)
self = create_self('Michael', 190, birthdate)
print(get_description(self))
You may also like…
- Why fluentd loss most of it's log while using http output plugin (in similar timestamp)
- Java Mouse Listener – Can event type be detected inside of an event?
- flutter build ipa works locally, but not when run on github actions on the same machine
- CSS Imported by a Dependency
- Module '"rxjs"' has no exported member 'firstValueFrom'
- what use spring multiple handler websocket session service
- Failing to increment pair count correctly add_pairs Tideman CS50
- How can I get the average cost from a specific column from a table in R
- The theme system is not working for me and I'm not sure why
- Sorting multiple rows of un-sorted data based on text string – GSheets
- Tkinter RuntimeError: main thread is not in main loop when trying to insert item into listbox from different thread
- SwiftUI: Generating a continuous alphabetical list (from a-z then from aa, bb, cc, …, aaa, bbb, ccc)
- AWS Eventbridge rule trigger once all in-flight sqs messages are processed
- Avoid calling a method in a loop
- How to add a single value in datagridview with c#?
- MenuItem with onClick={popupState.close} in Material-ui V 5.0 how to execute a Link to open the component?
amazon-web-services android angular api arrays c# css dart dataframe django docker excel express firebase flutter html ios java javascript jquery json kotlin laravel linux list mongodb mysql node.js pandas php postgresql python python-3.x r react-native reactjs regex spring spring-boot sql sql-server string swift typescript vue.js