import math # Function 1: Print "Hello" def print_hello(): print("Hello") # Function 1.2: Returns the string "Hello" # You need to call this function INSIDE a print statement # to display "Hello" onto the terminal def return_hello(): return "Hello" # Function 2: Area of a circle def area_of_circle(r): return math.pi*(r**2) # Function 3: Counting vowels in a SINGLE string # Iterates through each character in the string word def count_vowels(word): count = 0 for i in word: if i.lower() == 'a' or i.lower() == 'e' or i.lower() == 'i' or i.lower() == 'o' or i.lower() == 'u': # True as long as one of these cases is True (you can also use if-elifs) count+=1 # Same as count = count + 1 return count # Function 4: Counting vowels in all strings in a list # Makes repeated calls to the function count_vowels() but # with a different string each time (because of the for-loop) # Think of count_vowels() as a tool, if you give it a string # it gives you the vowel count def count_vowels_in_list(word_list): total_vowel_count = 0 for word in word_list: single_word_vowel_count = count_vowels(word) # word is a different string each time this function is called total_vowel_count+=single_word_vowel_count return total_vowel_count #----------------------------------------------------------------------------------------------------------------------------------------------- # You can only call your functions AFTER you've declared them # If you try running these statements before the function has been written you will get an error! print_hello() print(return_hello()) print(area_of_circle(2)) print(count_vowels("Seattle")) locations = ["Seattle", "Washington", "California", "Los Angeles"] print(count_vowels_in_list(locations))