I am new to Python. In my module- Utility.py, the function below takes in the age and gender of a person. It returns the fees this person has to pay based on his/her age and gender. I'm not allowed to make any changes to this module.
def get_fees(age, gender):
if gender == 'M':
if age >= 50:
return 300
elif age >= 35:
return 250
else:
return 150
else:
if age >= 50:
return 320
elif age >= 35:
return 270
else:
return 160
I also made a new module, PrintFees.py, where I need to prompt the user for the age and gender and then pass the inputs to the function (get_fees) that I need to call from the Utility module. I also need to print the fees needed.
Here is what I tried:
import Utility
age= int(input("What's your age? " ))
gender = input("What's your gender? [M|F]")
#Print fees
print("Your fees is $", Utility.get_fees(age,gender))
When I tried to run, this error message appeared.
Traceback (most recent call last):
File "printfees.py", line 7, in <module>
print("Your fees is $", Utility.get_fees(age,gender))
NameError: name 'Utility' is not defined
How do I solve this problem? Thanks.