Question: # This program uses a function to calculate the # total of the values in a list. def main(): # Create a list. numbers =

 # This program uses a function to calculate the # total

# This program uses a function to calculate the # total of the values in a list. def main(): # Create a list. numbers = [2, 4, 6, 8, 10] Program Output The total is 30 # Display the total of the list elements. print('The total is', get_total(numbers) # The get_total function accepts a list as an # argument returns the total of the values in # the list. Note the call to the function. It passes the list, via its name, as an argument! In-Class Exercise (see canvas!). def get_total(value_list): # Create a variable to use as an accumulator. total = 0 1) Important! Type this code in and try this! # Calculate the total of the list elements. for num in value_list: total += num 2) Modify your code by creating another function that receives a list of numbers and returns BOTH the total and average of the list of numbers. Print the total and average from main() (6pts. See Canvas) # Return the total. return total # Call the main function. main() Also, see program 7-11 return_list.py in your textbook

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!