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 a Python program that stores the data for each player on the team, and it...

    Write a Python program that stores the data for each player on the team, and it also lets the manager set a starting lineup for each game. Questions: - Handle the exception that occurs if the program can’t find the data file. - Handle the exceptions that occur if the user enters a string where an integer is expected. - Handle the exception that occurs if the user enters zero for the number of at bats. - Thoroughly test the...

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

  • Note: You must write this program in Python. General Requirements The program should display a menu...

    Note: You must write this program in Python. General Requirements The program should display a menu and allow the user to perform one of the following tasks. Add an item to the list Delete an item from the list Print the list Print the list in reverse Quit the program The program should run until the user chooses to quit. In Python, programmatically quitting the application is achieved with the exit() procedure. You should use a List to store the...

  • Objectives: Integer arithmetic, Functions, menus. Write a C++ program that displays the following menu of choices....

    Objectives: Integer arithmetic, Functions, menus. Write a C++ program that displays the following menu of choices. 1. Find the number of digits in an integer. 2. Find the nth digit in an integer. 3. Find the sum of all digits of an integer. 4. Is the integer a palindrome? 5. Quit Enter a choice: Page 1 of 4 For each of the choices (1, 3, 4), Read a positive integer number and call a function that processes the menu choice...

  • (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...

  • Write a perl program Use a while loop to get user input until the user enters...

    Write a perl program Use a while loop to get user input until the user enters "quit" Use a regex to replace any occurrence of the word "python" with the word "perl" and print out the updated version Provide the perl program (.pl file) as well as a screenshot of the output (show at least one example with python being replaced)

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