274,724 views
28 votes
28 votes
Write a function named partc that will take in as parameters a single character, a person’s name, company, and email, and returns a single string of the person’s digital business card. Use the character as a border, and provide 2 spaces as padding on either side of the longest entry. Your function must return a single string, do not print the digital card.

User Shia G
by
3.1k points

1 Answer

9 votes
9 votes

Final answer:

The function 'partc' generates a digital business card with a border and padding, taking in a character, a name, company, and email as parameters. It can be implemented in any programming language; the example provided is in Python.

Step-by-step explanation:

The student is asking to write a function named partc that creates a digital business card. The function takes in four parameters: a character for the border, and strings for a person's name, their company, and their email address. The function then returns a single string formatted as a digital business card with the provided character as a border and padding around the longest entry.

This function can be written in any programming language, but for the purpose of this example, here's how you might write it in Python:

def partc(border_char, name, company, email):
lines = [name, company, email]
max_length = max(len(line) for line in lines) + 4 # 2 spaces padding on each side
border_line = border_char * (max_length + 2) # +2 for the border

card_lines = [border_line] + ['{} {} {}'.format(border_char, line.ljust(max_length), border_char) for line in lines] + [border_line]
return '\\'.join(card_lines)
This code snippet illustrates a possible function implementation for creating a digital business card.

User Deep Patel
by
3.2k points