Iterate over the list find the smallest number in the list


Python programming

List practice

  1. Create a list of numbers. For example my_list = [5, 8,100,1,5,-2]
  2. Iterate over the list, find the smallest number in the list, and print it.
  3. Iterate over the list, find the largest number in the list, and print it.
  4. Iterate over the list, add all the numbers and print the sum of all numbers.
  5. 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.
  6. 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] 

Solution Preview :

Prepared by a verified Expert
Business Management: Iterate over the list find the smallest number in the list
Reference No:- TGS02483217

Now Priced at $30 (50% Discount)

Recommended (95%)

Rated (4.7/5)