Question: hello. need help with python 6. Complete the body of the format_name function. This function receives first_name and last_name, then prints a formatted string of
hello. need help with python
6. Complete the body of the format_name function. This function receives first_name and last_name, then prints a formatted string of "Name: last_name, first_name" if both names are not blank, or "Name: " with just one of the names, if the other one is blank, and nothing if both are blank. 1- def format_name(first_name, last_name): # code goes here return " 4 print(format_name ("Ernest", "Hemingway")) # Should be "Name: Hemingway, Ernest" print(format_name ("", "Madonna")) # Should be "Name: Madonna" 10 print(format_name("Voltaire", "")) # Should be "Name: Voltaire" 11 Run 12 13 print(format_name("", "")) # Should be 14 Reset 15 7. The longest_word function is used to compare 3 words. It should return the word with the most number of characters (and the first in the list when they have the same length). Fill in the blank to make this happen. 1- def longest_word(word1, word2, word3): if len(word1) >= len(word2) and len(word1) >= len(word3): word = word1 elif : 4 - word = word2 else: word = word3 return(word) Run print(longest_word("chair", "couch", "table")) print(longest_word("bed", "bath", "beyond")) print(longest word("laptop", "notebook", "desktop")) 10 11 Reset 12 What's the output of this code? 8. 1 - def sum(x, y): return(x+y) print(sum(sum(1,2), sum(3,4)))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
