# Let's define a function. def function_name(argument_1, argument_2): # Do whatever we want this function to do, # using argument_1 and argument_2 # Use function_name to call the function. function_name(value_1, value_2) print("You are doing good work, Adriana!") print("Thank you very much for your efforts on this project.") print("\nYou are doing good work, Billy!") print("Thank you very much for your efforts on this project.") print("\nYou are doing good work, Caroline!") print("Thank you very much for your efforts on this project.") def thank_you(name): # This function prints a two-line personalized thank you message. print("\nYou are doing good work, %s!" % name) print("Thank you very much for your efforts on this project.") thank_you('Adriana') thank_you('Billy') thank_you('Caroline') thank_you('Adriana') thank_you('Billy') thank_you('Caroline') def thank_you(name): # This function prints a two-line personalized thank you message. print("\nYou are doing good work, %s!" % name) print("Thank you very much for your efforts on this project.") students = ['bernice', 'aaron', 'cody'] # Put students in alphabetical order. students.sort() # Display the list in its current order. print("Our students are currently in alphabetical order.") for student in students: print(student.title()) # Put students in reverse alphabetical order. students.sort(reverse=True) # Display the list in its current order. print("\nOur students are now in reverse alphabetical order.") for student in students: print(student.title()) ###highlight=[2,3,4,5,6,12,16] def show_students(students, message): # Print out a message, and then the list of students print(message) for student in students: print(student.title()) students = ['bernice', 'aaron', 'cody'] # Put students in alphabetical order. students.sort() show_students(students, "Our students are currently in alphabetical order.") #Put students in reverse alphabetical order. students.sort(reverse=True) show_students(students, "\nOur students are now in reverse alphabetical order.") def show_students(students, message): # Print out a message, and then the list of students print(message) for student in students: print("- " + student.title()) students = ['bernice', 'aaron', 'cody'] # Put students in alphabetical order. students.sort() show_students(students, "Our students are currently in alphabetical order.") #Put students in reverse alphabetical order. students.sort(reverse=True) show_students(students, "\nOur students are now in reverse alphabetical order.") def get_number_word(number): # Takes in a numerical value, and returns # the word corresponding to that number. if number == 1: return 'one' elif number == 2: return 'two' elif number == 3: return 'three' # ... # Let's try out our function. for current_number in range(0,4): number_word = get_number_word(current_number) print(current_number, number_word) ###highlight=[13,14,17] def get_number_word(number): # Takes in a numerical value, and returns # the word corresponding to that number. if number == 0: return 'zero' elif number == 1: return 'one' elif number == 2: return 'two' elif number == 3: return 'three' else: return "I'm sorry, I don't know that number." # Let's try out our function. for current_number in range(0,6): number_word = get_number_word(current_number) print(current_number, number_word) ###highlight=[16,17,18] def get_number_word(number): # Takes in a numerical value, and returns # the word corresponding to that number. if number == 0: return 'zero' elif number == 1: return 'one' elif number == 2: return 'two' elif number == 3: return 'three' else: return "I'm sorry, I don't know that number." # This line will never execute, because the function has already # returned a value and stopped executing. print("This message will never be printed.") # Let's try out our function. for current_number in range(0,6): number_word = get_number_word(current_number) print(current_number, number_word)