Write a python program to calculate average of numbers from 1 to 10.
Answers
Answered by
1
Answer:
n=int(input("Enter the number of elements to be inserted: "))
a=[]
for i in range(0,n):
elem=int(input("Enter element: "))
a.append(elem)
avg=sum(a)/n
print("Average of elements in the list",round)
Answered by
4
Required Answer:-
Question:
- Write a Python program to calculate average of numbers from 1 to 10.
Solution:
Here is the program.
s=0
for i in range(1,10+1):
s+=i
s=s/10
print("Average of first 10 numbers: ",s)
Another way of solving,
s=sum([i for i in range(1, 11)])/10
print("Average is: ", s)
Explanation:
- We will find out th sum of numbers from 1 to 10 using loop. After finding out the sum, we will divide the sum by 10 as there are ten numbers (1 to 10). After dividing by 10, we will get the average.
Output:
Average of first 10 numbers: 5.5
Refer to the attachment.
Attachments:
Similar questions