Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON: My professor commented this on my code: did not setup the occurs on method correctly. It needs to have the same # of inputs
PYTHON:
My professor commented this on my code: did not setup the occurs on method correctly. It needs to have the same # of inputs in all sub classes.
Can anyone please check my code and explain what did I do wrong and how to fix the code according to what my professor commented.
my code:
st file : Acct.py:
class Appt:
def initself month, day, year, desc:
self.month month
self.day day
self.year year
self.desc desc
def OccursOnself month, day, year:
pass
class MonthAppt:
def OccursOnself month:
if self.month month:
return True
return False
class DayAppt:
def OccursOnself day:
if self.day day:
return True
return False
class DateAppt:
def OccursOnself month, day, year:
if self.month month and self.day day and self.year year:
return True
return False
nd file : Appt Main code.py:
from Appt import
# Sample appointments
appts
Month None, None, "Dental cleaning"
Month None, None, "Root"
DayNone None, "Crown"
Date "Braces adjustment"
Date "Pull Teeth"
# Ask user for input
dateinput inputEnter a date MM DD YYYY: split
monthinput intdateinput
dayinput intdateinput
yearinput intdateinput
option inputEnter 'Month', 'Day', or 'Date' to check against appointments: capitalize
# Check for appointments based on user input
found False
if option "Month":
for appt in appts:
if isinstanceappt Month and appt.OccursOnmonthinput:
printMatching Appointment:", appt.desc
found True
elif option "Day":
for appt in appts:
if isinstanceappt Day and appt.OccursOndayinput:
printMatching Appointment:",appt.desc
found True
elif option "Date":
for appt in appts:
if isinstanceappt Date and appt.OccursOnmonthinput, dayinput,yearinput:
printMatching Appointment:",appt.desc
found True
if not found:
printNo appointments found."
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started