Question: Using python 3 List practice Create a list of numbers. For example my_list = [5, 8,100,1,5,-2] Iterate over the list, find the smallest number in
List practice
- Create a list of numbers. For example my_list = [5, 8,100,1,5,-2]
- Iterate over the list, find the smallest number in the list, and print it.
- Iterate over the list, find the largest number in the list, and print it.
- Iterate over the list, add all the numbers and print the sum of all numbers.
- Ask the user to input a number to search for in the list and count occurrences of. Iterate over the list and tell the user the index for the first occurrence of the number if the number was found in the list. Make sure this also works for the case when the number you are searching for is not in the list.
- Iterate over the list and tell the user the count of number of times the specified number appears in the list.
To demonstrate, generate sample output as follows:
The smallest number in [5,8,100,1,5,-2] is -2
The largest number in [5,8,100,1,5,-2] is 100
Sum of all numbers in [5,8,100,1,5,-2] is 117
Enter the number to find in the list and also count occurrences of?5
5 was found at index 0 of [5,8,100,1,5,-2]
5 occurs 2 times in [5,8,100,1,5,-2]
Note: do not use the built-in min, max, find, or sort functions.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
