The quiz where the difficulty automagically adapts to the player's Python knowledge
This is a question page. You can use this page to bookmark a question. Start a new quiz!
Question #358
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])
print(result_avg)
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. (w3schools.com/python/gloss_python_global_variables.asp)
Question difficulty: 🔵🔵🔵🔵🔵