Question: Hello! I am a beginner Python programmer. I'm trying to create a menu of options with three applications. the first problem is that I have
Hello! I am a beginner Python programmer. I'm trying to create a menu of options with three applications. the first problem is that I have finished the grade book application, but when I try to run, the grade book application function it doesn't won't appear. I don't know why. And the second problem is Trip Expense Calculation, should there be two function or one there? Thank you.
from os import system,name
def clear(): if name== 'nt': _ = system, ('cls') else: _ = system('clear')
def gradebook(): clear() print("This is Grade Book Application") input(" Press any Key to continue") clear()
def payrollapp(): clear() print("This is Payroll Application") input("Press any Key to continue") clear()
def tripexpense(): clear() print("This is Trip Expense Calculation") input("Press any Key to continue") clear()
choice=''
while(choice!='d'): print("Menu of options") print("=============== ") print("a. Go to Grade Book Application") print("b. Go to Payroll Application") print("c. Go to Trip Expense Calculation") print("d. To Quit ") choice=str(input("Enter your choice ==>")) if(choice=='a'): def gradebook(): def getInput(datatype,prompt):
num=datatype(input(prompt))
if num
#negative input,printing error message and asking again
print('Please enter a positive value!')
#asking again
return getInput(datatype,prompt)
else:
#positive value, returning
return num
#fetching number of students and grades
numStudents=getInput(int,'Enter number of students:')
numGrades=getInput(int,'Enter number of grades:')
totalAvg=0 #to store total average of all students
#looping through 0-numStudents-1
for i in range(numStudents):
total=0 #to store total score of this student
#getting all scores of this student
for j in range(numGrades):
total+=getInput(float,'Enter student {:d}\'s test {:d} score:'.format(i+1,j+1))
#finding and displaying average score
avg=totalumGrades
if (avg>=90): print("Your grade is A") elif (avg>=80): print("your grade is B") elif (avg>=70): print("Your grade is C") elif (avg>=60): print("Your grade is D") else: print("Your grade is F")
print('Average score of student {:d} is {:.2f}'.format(i+1,avg)) elif(choice=='b'): payrollapp() def SimpleCalc(h,p): return h*p
def CalcPay(h, p): if(h ")) payrate=float(input("Enter the Pay Rate ==> "))
you=CalcPay(hours, payrate) print("Your weekly pay is ==> ", you)
elif(choice=='c'): tripexpense() def CalcTripExp(md, mpg, gp, tp, tt): return (md/mpg)*gp+tp+tt print(" ") print("Calculate the trip expense") print("========================== ") milesdrive=float(input("Enter the total miles drive: ")) gallonofgasoline=float(input("Enter the cost per gallon of gasoline : ")) gasoline=float(input("Enter the average miles per gallon : ")) parking=float(input("Enter the total parking fees : ")) tools=float(input("Enter the total tolls for the trip : ")) totalcost=CalcTripExp(milesdrive, gallonofgasoline, gasoline, parking, tools ) print("Your total cost for the trip" , totalcost) elif(choice=='d'): clear() print("Thanks for using this App ") else: clear() print("Wrong Option -- Enter Again") input("Press any Key to continue") clear()

Menu of options == ========== === a. Go to Grade Book Application b. Go to Payroll Application C. Go to Trip Expense Calculation d. To Quit Enter your choice ==>a Menu of options =============== a. Go to Grade Book Application b. Go to Payroll Application C. Go to Trip Expense Calculation d. To Quit Enter your choice ==>b This is Payroll Application Press any key to continue Payroll Calculator =================== Enter the hours worked==>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
