Question

Using Python code. Fill in the gaps in the nametag function so that it uses the...

Using Python code.

Fill in the gaps in the nametag function so that it uses the format method to return first_name and the first initial of last_name followed by a period. For example, nametag("Jane", "Smith") should return "Jane S."

def nametag(first_name, last_name):
   return("___.".format(___))

print(nametag("Jane", "Smith"))
# Should display "Jane S."
print(nametag("Francesco", "Rinaldi"))
# Should display "Francesco R."
print(nametag("Jean-Luc", "Grand-Pierre"))
# Should display "Jean-Luc G."

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def nametag(first_name, last_name):
    return ("{} {}.".format(first_name, last_name[0]))


print(nametag("Jane", "Smith"))
# Should display "Jane S."
print(nametag("Francesco", "Rinaldi"))
# Should display "Francesco R."
print(nametag("Jean-Luc", "Grand-Pierre"))
# Should display "Jean-Luc G."

Add a comment
Know the answer?
Add Answer to:
Using Python code. Fill in the gaps in the nametag function so that it uses the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In python class Customer: def __init__(self, customer_id, last_name, first_name, phone_number, address): self._customer_id = int(customer_id) self._last_name =...

    In python class Customer: def __init__(self, customer_id, last_name, first_name, phone_number, address): self._customer_id = int(customer_id) self._last_name = str(last_name) self._first_name = str(first_name) self._phone_number = str(phone_number) self._address = str(address) def display (self): return str(self._customer_id) + ", " + self._first_name + self._last_name + "\n" + self._phone_number + "\n" + self._address customer_one = Customer("694", "Abby", "Boat", "515-555-4289", "123 Bobby Rd", ) print(customer_one.display()) customer_two = Customer ("456AB", "Scott", "James", "515-875-3099", "23 Sesame Street Brooklyn, NY 11213") print(customer_two.display()) Use Customer class remove the address attribute.Place the code...

  • Write a program that does the following in Python Code: Stores the following three lists: last_name...

    Write a program that does the following in Python Code: Stores the following three lists: last_name = ["Smith", "Jones", "Williams", "Bailey", "Rogers", "Pyle", "Rossington"] first_name =["Lisa", "Bill", "Jay", "Sally", "Walter","Jake","Gary"] phone_number =["240-233-1921", "301-394-2745", "571-321-8934", "703-238-3432", "703-947-9987", "301-945-3593", "240-671-3221"] Has a function named combine_lists() that takes in last_names, first_names and phone_numbers as lists and returns a dictionary called phone_book that uses last_name as the key and a list consisting of first_name and phone_number. Has a main function that iterates through the...

  • Python help! Any help is appreciated, thank you! Fill in the missing function, monthString(), in the...

    Python help! Any help is appreciated, thank you! Fill in the missing function, monthString(), in the program. The function should take number between 1 and 12 as a parameter and returns the corresponding month as a string. For example, if the parameter is 1, your function should return "January". If the parameter is 2, your function should return out "February", etc. def monthString(monthNum): """ Takes as input a number, monthNum, and returns the corresponding month name as a string. Example:...

  • Write a program that does the following in Python Code: Stores the following three lists: last_...

    Write a program that does the following in Python Code: Stores the following three lists: last_name = ["Smith", "Jones", "Williams", "Bailey", "Rogers", "Pyle", "Rossington"] first_name =["Lisa", "Bill", "Jay", "Sally", "Walter","Jake","Gary"] phone_number =["240-233-1921", "301-394-2745", "571-321-8934", "703-238-3432", "703-947-9987", "301-945-3593", "240-671-3221"] Has a function named combine_lists() that takes in last_names, first_names and phone_numbers as lists and returns a dictionary called phone_book that uses last_name as the key and a list consisting offirst_name and phone_number. Has a main function that iterates through the phone_book...

  • [Using Python] I need my code given below to loop the user input, so that you...

    [Using Python] I need my code given below to loop the user input, so that you are asked to input without it stopping after 4 inputs. Code: #A program that converts a hexadecimal number to its decimal value #Define function for hexadecimal to decimal def hexToDec(hexi): result = 0 #For loop to test input for correct values for char in hexi: if 'A' <= char <= 'F' or 'a' <= char <= 'f': if 'a' <= char <= 'f': result...

  • Python 3+ Adjust the following code so the two errors below are non-present: 1. __init__() :...

    Python 3+ Adjust the following code so the two errors below are non-present: 1. __init__() : Since Pizza object don't have it's own set() datastructure, the toppings in the pizza object are manimupated from out of the object. (-1.0) 2. __eq__() : How about "self.toppings == other.toppings" rather than "self.toppings - other.toppin == set())". Code: ## Program 1 ## --------------------------------- class Pizza: def __init__(self, s='M', top=set()): self.setSize(s) self.toppings = top def setSize(self, s): self.size = s def getSize(self): return self.size...

  • The group_list function accepts a group name and a list of members, and returns a string...

    The group_list function accepts a group name and a list of members, and returns a string with the format: group_name: member1, member2, … For example, group_list("g", ["a","b","c"]) returns "g: a, b, c". Fill in the gaps in this function to do that. def group_list(group, users): members=[] members += "," .join(users)    return ("{}:{}".format(group,users)) print(group_list("Marketing", ["Mike", "Karen", "Jake", "Tasha"])) # Should be "Marketing: Mike, Karen, Jake, Tasha" print(group_list("Engineering", ["Kim", "Jay", "Tom"])) # Should be "Engineering: Kim, Jay, Tom" print(group_list("Users", "")) #...

  • Write a Python Code for a Function: you need to come up with code for shift_char....

    Write a Python Code for a Function: you need to come up with code for shift_char. Write the code in a way in which you can shift the character by writing the number of shifts. Use the ASCII code for this. For example in lie 11, the input for char_to shift is r. U shift it by 1 so it becomes s. below is the function def shift_char(char_to_shift, amount_to_shift): ''' shifts any character by moving it a certain amount on...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is sued. Write a Python...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is sued. Write a Python code that gets a string containing a person’s first, middle, and last name, and print her/his last name, followed by comma and the first name initial. For example, if the user enters Randy Rick Gomez, the program should display Gomez, R. Please note that in the output, the first character of each name should be capital. Please see the outcomes below: Outcome: Enter your...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT