question archive To whom it may concern, I'm currently working on a Menu Drive Interface program assignment involving While functions in Python

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:

  1. Choose to exit
  2. Choose to display the scores from highest to lowest values.
  3. Choose to add a score to the list. Note that scores must be floating point numbers.
  4. Choose to display the highest and lowest scores.

Your program should demonstrate secure software best practices as follows:

  • You have to make a list with three initial floating point values: 85.3, 85.2 and 21.99. Remember, '85.3' is a string whereas 85.3 is a number.
  • Use the if/else construct to ensure that new scores entered by the user are between 0.0 and 100.0.
  • To get the highest and lowest score, sort the list and use indexing. Use the len() function to get the number of items in the list and then subtract 1 to get the index of the last item in the list.
  • Provide the user with useful information. If the score entered is outside of the range, let the user know if the score is too high or if it's too low. If the user enters an invalid menu selection, let her/him know what's wrong.
  • Use the print format specifier to set the number of digits to the right of the decimal point to two for the scores displayed.
  • Your program should include header comments at the top of the file that specify your name, the date, the name of the assignment and the course identifier.
  • For #4, make sure you use indexes. Cannot use the min() and max() functions. Instead, use the len() function, which provides the number of elements in the list. Subtracting 1 from the number gives you the index of the last element in the list. Use the sort() method to order the scores in the list.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

#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.