Bird
0
0

You want to create a method format_name that takes two parameters first and last and returns the full name in uppercase. Which code correctly does this?

hard📝 Application Q8 of 15
Python - Methods and Behavior Definition
You want to create a method format_name that takes two parameters first and last and returns the full name in uppercase. Which code correctly does this?
Adef format_name(first, last): return first + last.upper()
Bdef format_name(first, last): print(first + last).upper()
Cdef format_name(first, last): return first.upper() + last.upper()
Ddef format_name(first, last): return (first + ' ' + last).upper()
Step-by-Step Solution
Solution:
  1. Step 1: Understand the requirement

    Return full name with first and last separated by space, all uppercase.
  2. Step 2: Check each option

    def format_name(first, last): return (first + ' ' + last).upper() concatenates with space and applies upper() to whole string, correct.
  3. Final Answer:

    def format_name(first, last):\n return (first + ' ' + last).upper() -> Option D
  4. Quick Check:

    Concatenate with space then uppercase [OK]
Quick Trick: Use parentheses to uppercase full concatenated string [OK]
Common Mistakes:
  • Using print instead of return
  • Uppercasing parts separately without space
  • Missing space between names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes