Problem StatementWrite a program to find the average of N numbers. Print the average in 2 digit precision DO NOT USE ARRAYInput FormatFirst line consist of a single integer - 'N'Second line consist of N space separated integersOutput FormatDisplay the average of N numbersSample Input51 2 3 4 5Sample Output3.00
Question
Problem StatementWrite a program to find the average of N numbers. Print the average in 2 digit precision DO NOT USE ARRAYInput FormatFirst line consist of a single integer - 'N'Second line consist of N space separated integersOutput FormatDisplay the average of N numbersSample Input51 2 3 4 5Sample Output3.00
Solution
Sure, here is a Python solution for the problem:
# Step 1: Get the input from the user
N = int(input())
numbers = list(map(int, input().split()))
# Step 2: Calculate the sum of the numbers
sum_of_numbers = sum(numbers)
# Step 3: Calculate the average
average = sum_of_numbers / N
# Step 4: Print the average with 2 digit precision
print("{:.2f}".format(average))
Here is
Similar Questions
import java.util.Scanner; public class Test1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter three numbers: "); float number1 = input.nextInt(); float number2 = input.nextInt(); float number3 = input.nextInt(); float number4 = input.nextInt(); // Compute average double average = (number1 + number2 + number3 + number4) / 4; // Display result System.out.println(average); } } When a user enters 1 2 3 4 during the program execution what will be the exact output? Group of answer choices2.02.53.0The program gives an error.
Initialize an array/list with five integers. Write a program to find the sumand average of these n
Write a program that repeatedly asks for numbers. When the user enters 0, the program prints the average of all numbers entered (excluding the 0) accurate to two decimal places and exits.
Q4 - Average Of all Array ElementsWrite a Program to Find the average of all elements in a Given Array?Constraints:Input :- First Line of Input Consists of One Integer Value (Array Size). Second Line of Input Consists of few Integer Values Separated by Space (Array Elements).Output :- Print the Average of All the Array Elements.Constraints :- Array Size must be Greater then 0 or else Print "Invalid ArRay Size.". Print the Average value upto 5 Decimal points.Example:Input 1 : 6 10 02 20 21 11 54Output 1: Average of Given Array Elements is 19.66666. Input 2 : 4 1 2 3 0Output 2: Average of Given Array Elements is 1.50000.Explanation:Input 1 : 6 10 02 20 21 11 54Output 1: 19.66666Explanation: Sum = 10 + 02 + 20 + 21 + 11 + 54 = 118 Average = 118 / 6 = 19.66666. Input 2 : 4 1 2 3 0Output 2: 1.50000.Explanation: Sum = 1 + 2 + 3 + 0 = 6 Average = 6 / 4 = 1.55555.
In Statistics, Mean (average) is a common term used to analyze the data. Thus, we should know how to program this Statistical term using Python. For this, write a Python program to calculate the sum and average (Mean) of n integer numbers (input from the user). Input 0 to finish the list.Sample:Input some integers to calculate their sum and average. Input 0 to exit .1516120Average and Sum of the above numbers are: 14.333333333333334 43.0
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.