Write 3 For loops to find the Mean, Maximum Value and
Minimum Value. Of a list of numbers. Some numbers should have
decimals. Do not ask the user to enter numbers. The numbers should
be in a premade list.
Then print
The average is " "
The largest value is " "
The smallest value is " "
SOURCE CODE: *Please follow the comments to better understand the code. **Please look at the Screenshot below and use this code to copy-paste. ***The code in the below screenshot is neatly indented for better understanding. # Initialise the list. lst = [0.2, 10, 5.6, 7, 8.9, 12, 5] # Take the initial variables # Take the sum to 0 initially sum = 0 largest = lst[0] # Let the first number be the largest and we will update it smallest = lst[0] # Let the first number be the smallest and we will update it # FOR loop for average for num in lst: # Add each number sum += num avg = sum / len(lst) print('The average is', avg) # FOR loop for Largest number for num in lst: # Check if this number is larger if num > largest: largest = num # print the largest number print("The largest value is", largest) # FOR loop for Smallest number for num in lst: # Check if this number is smaller if num < smallest: smallest = num # print the smallest number print("The smallest value is", smallest)
=================
SCREENSHOTS:
OUTPUT:
Get Answers For Free
Most questions answered within 1 hours.