HELP PYTHON PLEASE...AL THE ANSWERS FOR THIS ON CHEGG IS WRONG...NONE OF THEM RU
ID: 3830633 • Letter: H
Question
HELP PYTHON PLEASE...AL THE ANSWERS FOR THIS ON CHEGG IS WRONG...NONE OF THEM RUNS!!!
Python Help Please....
Part #1: Month class
Design a Python class for a calendar month. You class should have the following methods:
__init__ (self, name, days, first): start is the day of the week that the first falls on.
getName(self): returns the name of the month
getDays(self): returns the number of days
getFirst(self): returns the first day of the month
Add a main() method to the script that creates a couple month objects and calls the three get() methods of each to display to the screen.
Explanation / Answer
class Month:
def __init__(self, name, days, first):
self.name = name
self.days = days
self.first = first
def getName(self):
return self.name
def getDays(self):
return self.days
def getFirst(self):
return self.first
def main():
month = Month("May", 31, "Monday")
print(month.getName())
print(month.getDays())
print(month.getFirst())
month = Month("April", 30, "Saturday")
print(month.getName())
print(month.getDays())
print(month.getFirst())
month = Month("June", 30, "Thrusday")
print(month.getName())
print(month.getDays())
print(month.getFirst())
if __name__ == '__main__':
main()
# code link: https://paste.ee/p/SSEac
Please comment if you have face any issue, else give a thumbs up.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.