Python Programming - Multithreading, OOP, NumPy and Pandas
14. Loops - while loop
Calculating the Average Exercise
Construct an application that calculates the average of the first 10 items - starting with 1. So [1,2,3,4,5,6,7,8,9,10] these are the numbers you have to consider - with loops of course :)
Good luck
================================================================
Calculating the Average Solution
item_counter = 0
sum = 0
for item in range(1, 11):
sum += item
item_counter += 1
print('Average of the first 10 items (starting with 1) is: ' + str(sum/item_counter))
نظرات