mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-30 16:31:08 +00:00
c92b02cfa3
* avrage.py calculate and print the avrage of number list. * Update base64_cipher.py encoding and decoding base64 without any module. * Update and rename avrage.py to average.py * update find_lcm algorithm I made find_lcm more efficient form O(num1*num2) to O(min{num1,num2}).
15 lines
207 B
Python
15 lines
207 B
Python
def average(nums):
|
|
sum = 0
|
|
n = 0
|
|
for x in nums:
|
|
sum += x
|
|
n += 1
|
|
avg = sum / n
|
|
print(avg)
|
|
|
|
def main():
|
|
average([2, 4, 6, 8, 20, 50, 70])
|
|
|
|
if __name__ == '__main__':
|
|
main()
|