In [1]:
def mean(nums):
bot = len(nums)
it = 0
top = 0
while it < len(nums):
top += nums[it]
return float(top) / float(bot)
a_list = [1, 2, 3, 4, 5, 6, 10, "one hundred"]
# Won't run!
#mean(a_list)
In [2]:
def mean(nums):
bot = len(nums)
it = 0
top = 0
print("Still Running at line 5")
while it < len(nums):
top += nums[it]
print(top)
return float(top) / float(bot)
a_list = [1, 2, 3, 4, 5, 6, 10, "one hundred"]
# Won't run!
#mean(a_list)
In [3]:
def mean(nums):
top = sum(nums)
bot = len(nums)
return float(top) / float(bot)
a_list = [1, 2, 3, 4, 5, 6, 10, "one hundred"]
mean(a_list)
In [4]:
import pdb
# uncomment to run pdb
#pdb.set_trace()
a_list = [1, 2, 3, 4, 5, 6, 10, "one hundred"]
mean(a_list)
In [5]:
a_list = [1, 2, 3, 4, 5, 6, 10, 100]
result = mean(a_list)
print(result)