#returns the average of num1, num2, and num3 def average_3_numbers(num1, num2, num3): the_sum = num1+num2+num3 average= the_sum/3 return average ### Let's test our function: #print( average_3_nums(3,4,5) ) #Returns the average of all the numbers in some_list #some_list must be a list of numbers def average_of_list(some_list): the_sum = sum(some_lst) length_of_list = len(some_list) average = the_sum / length_of_list return average #lst = [3,4,5,6] #print(average_of_list(lst)) ### Note: You don't have to pre-create a list. #You can place a new list directly in the function as the argument: #print(average_of_list([2,3,4])) ### What happens if we pass the function an emtpy list? #print(average_of_list([])) def guess_se(): secret="Djengo" guess = input("Enter the secret word: ") if guess==secret: print("You got it!!") print("Goodbye...") #guess_secret() def average_of_list_v2(lst): if len(lst)==0: return 0.0 total = sum(lst) return total/len(lst) #print(average_of_list_v2([3,4,5])) #print(average_of_list_v2([])) #test with an empty list # Iteration (loop) exercises using the function range() ##for i in range(2): ## print(i, end=" ") ##for i in range(3,13): ## print(i, end=" ") ##for i in range(0,10,2): ## print(i, end=" ") ##for i in range(0,24,3): ## print(i, end=" ") ##for i in range(3, 12, 5): ## print(i, end=" ") def count_characters(lst): num_chars = 0 for str in lst: num_chars = num_chars + len(str) return num_chars ##list_of_strings = ["hello","how are you?", "all is good, thank you very much"] ##print( count_characters(list_of_strings) )