Question #358

What is the output of the code snippet below?
def find_avg(list_num):
    result_sum = 0
    for num in list_num:
        result_sum += num
    result_avg = result_sum/len(list_num)
find_avg([5, 8, 5])

When the control calls print(result_avg) , result_avg , as a local variable whose scope is bound to find_avg , is no longer present in memory. It will throw a NameError exception. (

Comment on Disqus:

Question difficulty: 🔵🔵🔵🔵🔵