Question
Write a program as follows. Follow instructions carefully to avoid point deductions. All statements should be in the main function: create an empty list named
Write a program as follows. Follow instructions carefully to avoid point deductions. All statements should be in the main function: create an empty list named nums. use a loop to add 20 random integers, all in the range from 1-100, to nums. print the total of all list elements. print the highest number in the list. print the lowest number in the list. sort the list and then reverse it. use another loop to display the sorted numbers in descending order, all on the same line, separated by a single space. determine if 75 is in the list. If it is, report the index of its first occurrence. If it is absent from the list, indicate that, too. make a new list named middle_10 by slicing out the middle 10 elements of the descending list. Use a loop to display the elements in middle_10 all on one line. make an empty list named evens and another empty list named odds. use a loop to process nums, adding even elements and odd elements to their respective lists. print both evens and odds. Crude dumps inside [ ] as shown next are okay. Sample Output 1 List total: 712 Highest number: 85 Lowest number: 2 All list elements in descending order 85 83 67 67 58 53 50 49 30 28 23 21 20 20 16 15 14 8 3 2 75 not in the list Middle 10 after descending sort: 53 50 49 30 28 23 21 20 20 16 Even #s [58, 50, 30, 28, 20, 20, 16, 14, 8, 2] Odd #s [85, 83, 67, 67, 53, 49, 23, 21, 15, 3]
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