How to Make a Loop to Find the Average of a Group of Numbers in Python
Python is an excellent language when you need to quickly sketch out a solution to a simple problem, such as averaging a group of numbers. Unlike Java or C, there is practically no "boilerplate" code that is needed simply to get the system initialized.
Instructions
-
-
1
Open the "IDLE" Python debugger.
-
2
Type the following commands:
alist = [1,2,3,4,5,6,7]
sum = 0
for x in alist:
sum += xaverage = sum / len(alist)
print (average) -
-
3
Press "F5" on your keyboard to test the program.
-
1