Question
Write a Python program to do the following: (a) Ask the user to enter as many integers from 1 to 10 as he/she wants. Store
Write a Python program to do the following: (a) Ask the user to enter as many integers from 1 to 10 as he/she wants. Store the integers in a list. Every time after the user has entered an integer, use a yes/no type question to ask whether the user wants to enter another one. Display the list. (b) Display the largest element, the smallest element, the sum of all elements and the length of the list. (c) Calculate and display the average of the elements. (d) Reverse the order of the elements. Display the reversed list. (e) Move the last element to the front of the list, i.e., the last element becomes the first element while other elements remain the same. [Hint: Insert the last element to the front first, then delete the last element]
The following is an example:
Enter an integer from 1 to 10: 5
Enter another integer?[y/n] y
Enter an integer from 1 to 10: 9
Enter another integer?[y/n] y
Enter an integer from 1 to 10: 8
Enter another integer?[y/n] y
Enter an integer from 1 to 10: 5
Enter another integer?[y/n] y
Enter an integer from 1 to 10: 7
Enter another integer?[y/n] n
Number list: [5, 9, 8, 5, 7]
Largest element: 9
Smallest element: 5
Sum of all elements: 34
Length of list: 5
Average: 6.8
List reversed: [7, 5, 8, 9, 5]
Last element moved to front: [5, 7, 5, 8, 9]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started