Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedhello. 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Visualization A Practical Introduction

Authors: Kieran Healy

1st Edition

0691181624, 978-0691181622

More Books

Students also viewed these Databases questions

Question

=+Among top management?

Answered: 1 week ago