0

Python program for to calculate the average number in a list

Python programming

12th Dec 2018, 11:39 AM
Twinkle Tosse
Twinkle Tosse - avatar
12 Réponses
+ 4
So you add all the numbers you got and divide by the number of numbers. In Python you can get the number of elements in a list with the function len. You just take your list, let's say you call it my_list, and write: len(my_list) You get the number of elements in the list like this. So probably now you get an idea how to tackle the problem...? Now give it a try!
12th Dec 2018, 11:59 AM
HonFu
HonFu - avatar
+ 3
HonFu is a good mentor. Patient and guiding instead of giving answer directly, 👏👏👏👏
12th Dec 2018, 12:33 PM
Gordon
Gordon - avatar
+ 2
Let's see if he figures this out himself. :) Good luck, Twinkle Tosse, keep us posted!
12th Dec 2018, 12:38 PM
HonFu
HonFu - avatar
+ 1
How would you calculate an average of a few numbers in real life?
12th Dec 2018, 11:45 AM
HonFu
HonFu - avatar
+ 1
By adding of two numbers and divide by two
12th Dec 2018, 11:48 AM
Twinkle Tosse
Twinkle Tosse - avatar
+ 1
Add three numbers and divide by three
12th Dec 2018, 11:56 AM
Twinkle Tosse
Twinkle Tosse - avatar
+ 1
Maybe you want to tell him the function to add numbers too?
12th Dec 2018, 12:37 PM
Gordon
Gordon - avatar
0
Any answer
12th Dec 2018, 11:40 AM
Twinkle Tosse
Twinkle Tosse - avatar
0
And if it's three numbers?
12th Dec 2018, 11:54 AM
HonFu
HonFu - avatar
0
And if it's three numbers?
12th Dec 2018, 11:55 AM
HonFu
HonFu - avatar
0
How can we find average of numbers given in list in python ??
16th Jun 2020, 10:06 AM
Anjali Sharma
Anjali Sharma - avatar
0
sum(lst) / len(lst)
16th Jun 2020, 1:18 PM
Gordon
Gordon - avatar