Question

Write a program that stores the following data in a tuple: 54,76,32,14,29,12,64,97,50,86,43,12 The program needs to...

Write a program that stores the following data in a tuple:

54,76,32,14,29,12,64,97,50,86,43,12

The program needs to display a menu to the user, with the following 4 options:

1 – Display minimum

2 – Display maximum

3 – Display total

4 – Display average

5 – Quit

Make your program loop back to this menu until the user chooses option 5. Write code for all 4 other menu choices

using the python code and screenshot the python code for me. many thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Thanks for the question, here is the code in python, with screenshot

================================================================

def getChoice():
    print('[1] - Display Minimum')
    print('[2] - Display Maximum')
    print('[3] - Display Total')
    print('[4] - Display Average')
    print('[5] - Quit')
    choice = input('Enter your choice: ')
    return choice


def main():
    data = 54, 76, 32, 14, 29, 12, 64, 97,50, 86, 43, 12
    while True:
        choice = getChoice()
        if choice == '1':
            print('Minimum number: {}'.format(min(data)))
        elif choice == '2':
            print('Minimum number: {}'.format(max(data)))
        elif choice == '3':
            print('Total: {}'.format(sum(data)))
        elif choice == '4':
            total, count = sum(data), len(data)
            print('Average: {:.2f}'.format(total / count))
        elif choice == '5':
            print('Thanks. Bye!')
            break
        else
:
            print('Error: Invalid selection')


main()

================================================================

Add a comment
Know the answer?
Add Answer to:
Write a program that stores the following data in a tuple: 54,76,32,14,29,12,64,97,50,86,43,12 The program needs to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Python program that uses a tuple. Create a tuple of your matric subjects. The...

    Write a Python program that uses a tuple. Create a tuple of your matric subjects. The program must display the first element, the last element, and the length of the tuple. An explanation message should also be included. E.g. The length of the tuple is 4. The user needs to be prompted for a subject, and the code needs to find the subject in the tuple. The user needs to be informed whether or not the subject is included in...

  •   Write codes that will produce the screen as shown Firstly, the program prompts user to...

      Write codes that will produce the screen as shown Firstly, the program prompts user to enter his name. Then it will display Hello <user name>. Next it prints out a menu which contains 5 options (1- add two integers, 2- add two strings, 3- compute factorial, 4- reverse a string, 5- quit program). Code all 5 tasks appropriately. When the task is completed (not including quitting program of course), the menu pops up again and asks user to try...

  • (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator...

    (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1 - 4): If the user enters 1, the program should ask for the radius of the circle and then display its area. If the user enters 2, the program should ask for the length and width of...

  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

  • The purpose of this assignment is to get experience with an array, do while loop and...

    The purpose of this assignment is to get experience with an array, do while loop and read and write file operations. Your goal is to create a program that reads the exam.txt file with 10 scores. After that, the user can select from a 4 choice menu that handles the user’s choices as described in the details below. The program should display the menu until the user selects the menu option quit. The project requirements: It is an important part...

  • Write a program in Python that will: Here are following requirements to completing Menu shapes: 1....

    Write a program in Python that will: Here are following requirements to completing Menu shapes: 1. Create a "MENU" with 4 - 5 options have the user click the option and thereafter ask the user to enter the amount of stars from 1 - 50. From there your "for loop" will create the shape. Menu options need to be: 1. Filled Triangle 2. filled Square 3. This can be any shape such as a Square, circle, a different angle of...

  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

    C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...

  • Code a complete Java program for the following payroll application: First, hard code the following data...

    Code a complete Java program for the following payroll application: First, hard code the following data for the object ‘Employee’ into 4 separate arrays: SSN: 478936762, 120981098, 344219081, 390846789, 345618902, 344090917 First name      : Robert, Thomas, Tim, Lee, Young, Ropal Last name       : Donal, Cook, Safrin, Matlo, Wang, Kishal Hourly rate     : 12.75, 29.12, 34.25, 9.45,   20.95, 45.10 Hours worked: 45,        40,        39,       20,      44,        10 These 4 arrays must be declared inside the class and not within any method....

  • Can you help me write a Python 3.7 code for this question? Write a program using...

    Can you help me write a Python 3.7 code for this question? Write a program using functions and mainline logic which prompts the user to enter a number, then generates that number of random integers and stores them in a list. It should then display the following data to back to the user: The list of integers The lowest number in the list The highest number in the list The total sum of all the numbers in the list The...

  • In C++ write a simple menu program that displays a menu for the user in an...

    In C++ write a simple menu program that displays a menu for the user in an object-oriented technique. The menu should keep showing up until the user chooses to quit. Also, there is a sub-menu inside a menu. The user should get at least a line displayed after he or she chooses that particular option meaning if the user presses 1 for the read actors from the file. The output can look like "reading actors from a file" and then...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT