Question

Write 3 For loops to find the Mean, Maximum Value and Minimum Value. Of a list...

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 " "

Homework Answers

Answer #1
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:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1.Draw a flowchart to read 3 numbers: M, K and N and print the largest number...
1.Draw a flowchart to read 3 numbers: M, K and N and print the largest number of them. 2. Devolve an algorithm that allows the user to enter the count of number in a list followed by these numbers. The algorithm should find and output the minimum and maximum numbers in the list. 3. Develop an algorithm that inputs a series of number and output their average.
python Write a program to find the largest value. Ask the user to enter three numbers....
python Write a program to find the largest value. Ask the user to enter three numbers. Compare them and report the largest one. [Hint: The user is free to enter any three numbers. Some or all of them may be the same. Take this into consideration when you compare the numbers.] The following are some examples. Enter first number: 7 Enter second number: 14 Enter third number: 10.5 The largest number is: 14.0 Enter first number: 17 Enter second number:...
WRITE it in Python! how to Write a method named smallest largest that asks the user...
WRITE it in Python! how to Write a method named smallest largest that asks the user to enter numbers, then prints the smallest and largest of all the numbers typed in by the user. You may assume the user enters a valid number greater than 0 for the number of numbers to read. Here is an example dialogue: How many numbers do you want to enter? 4 Number 1: 5 Number 2: 11 Number 3: -2 Number 4: 3 Smallest...
JAVA Write an application that will input four positive integers from the user. The program should...
JAVA Write an application that will input four positive integers from the user. The program should print out the largest and smallest number. It should print how many of the numbers are even and how many are odd. It should print how many of the numbers are one digit and how many of the numbers are two digit. It should print out the sum of all even numbers and the sum of all odd numbers. It should print out the...
python: find the maximum value from a sequence of positive numbers. you should print out the...
python: find the maximum value from a sequence of positive numbers. you should print out the maximum number from the sequence. output: Keep entering positive numbers. enter a number: enter a number: enter a number: enter a number: enter a number: largest number entered: ...
Question1: Write a Python Program that asks for the grades of 5 quizzes and then prints...
Question1: Write a Python Program that asks for the grades of 5 quizzes and then prints the highest grade. [6 Marks] Question2: Write a Python Program that does the following tasks. [8 Marks] Create an empty list Ask the user for 5 positive numbers and append them to the list Find and print the sum of all the numbers in the list Delete the last element from the list and then print the list Question3: Consider you have the following...
C++ The problem is as below: The Greatest and Least of These Write a program with...
C++ The problem is as below: The Greatest and Least of These Write a program with a loop that lets the user enter a series of integers. The user should enter -99 to signal the end of the series. After all the numbers have been entered, the program should display the largest and smallest numbers entered.
Write a largestBelowValue(numbers, value) function that returns the largest number in the list numbers that is...
Write a largestBelowValue(numbers, value) function that returns the largest number in the list numbers that is smaller than value. Assume the numbers are always positive integers. Some example test cases (include these test cases in your program): >>>print(largestBelowValue([31, 5, 71, 53, 40, 17], 40)) 31 >>>print(largestBelowValue([31, 5, 71, 53, 40, 17], 41)) 40 returns None since no value is smaller than 2 in the list >>>print(largestBelowValue([31, 5, 71, 53, 40, 17], 2)) None
1. Find the absolute maximum value and the absolute minimum value, if any, of the function....
1. Find the absolute maximum value and the absolute minimum value, if any, of the function. (If an answer does not exist, enter DNE.) g(x) = −x2 + 4x + 9 maximum = minimum= 2. Find the absolute maximum value and the absolute minimum value, if any, of the function. (If an answer does not exist, enter DNE.) f(x) = x2 − x − 3 on [0, 3] 3. Find the absolute maximum value and the absolute minimum value, if...
In java : Write a program that will provide important statistics for the grades in a...
In java : Write a program that will provide important statistics for the grades in a class. The program will utilize a for-loop to read ten floating-point grades from user input. Include code to prevent an endless loop. Ask the user to enter the values, then print the following data: Average Maximum Minimum
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT