Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to calculate average in list python by using whil loop

def avg(list):
    s = 0
    total = 0.0
    while(s < len(list)):
        total = total + list[s]
        s = s+1
    return total/len(list)
ans = avg([1, 2, 3, 4, 5])
print(ans)
Comment

PREVIOUS NEXT
Code Example
Python :: python list comprehension index, value 
Python :: write a program to check whether a character is vowel or consonant in python 
Python :: python timestamp shift one day 
Python :: how to install threading module in python 
Python :: python hash string 
Python :: datetime.timedelta months 
Python :: how to change the favicon in flask 
Python :: how to convert index to column in pandas 
Python :: annaul sum resample pandas 
Python :: train test split pandas 
Python :: python request post 
Python :: compute count2(aacaagctgataaacatttaaagag, aaaaa). in python 
Python :: python convert twitter id to date 
Python :: python dir all files 
Python :: DataFrame.plot.line() method: | dataframe line plot 
Python :: python discord bot wait for response 
Python :: how to save to file in python 
Python :: rename one dataframe column python 
Python :: rock paper scissors game in python 
Python :: how to python hack 2021 course 
Python :: elbow method k means sklearn 
Python :: python code to get all file names in a folder 
Python :: pygame tetris game tutorial 
Python :: numpy slice array into chunks 
Python :: python detect color on screen 
Python :: factorise expression python 
Python :: set_interval() 
Python :: github black badge 
Python :: tqdm in python 
Python :: python read word document 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =