question archive To whom it may concern, I'm currently working on a Menu Drive Interface program assignment involving While functions in Python
Subject:Computer SciencePrice:6.89 Bought3
To whom it may concern, I'm currently working on a Menu Drive Interface program assignment involving While functions in Python. I know how to do most of the functions. However, I'm having a difficult time to put them to work together. I was hoping that you could help me with this assignment. Here's the instructions for the assignment.
You have to implement a menu driven interface for maintaining a list of scores. You will also validate user input to make sure that the score entered is within an acceptable range.
Your program should provide a menu driven interface using a while loop in which the user can do the following:
Your program should demonstrate secure software best practices as follows:
#menu for selecting options def menu(): print("1.exit") print("2.Display") print("3.Add scores") print("4.Display Highest and Lowest") #printing Highest and lowest score without using min() max() def High_low(list): #sort the list in reverse order list.sort(reverse=True) print("Highest score: {0:.2f}".format(list[0])) print("Lowest score: {0:.2f}".format(list[len(list)-1])) print() #print list from highest to lowest after sorting list using sort method def display(list): list.sort(reverse=True) for i in list: #format function is used to print upto 2 decimal places print("{0:.2f}".format(i)) print() #main function def main(): #creating list with initializing three scores given list=[85.3,85.2,21.99] #run program untill user select to exit while True: #call menu function menu() selection=int(input("Select: ")) #if user select to exit break the loop and exit program if selection==1: print("Good Bye!") break elif selection==2: #display list in reverse order by calling display function display(list) elif selection==3: #add score and try except is used to only enter floating score try: temp=float(input("Enter score: ")) #if user input score out of range repropt until correct value not inseted while temp<0.0 or temp>100.0: print("Oops! score is not in range......Try again!") temp=float(input("Enter score: ")) print() list.append(temp) except: print("Oops! invalid input........Try again\n") elif selection==4: #print Highest and lowest value by calling function High_low(list) else: #if user enter invalid choice print("Oops! invalid choice!") print() if __name__=="__main__": main() please see the attached file for the complete solution.