Bryce H.

asked • 02/25/23

how to code in python?

Create a new class called Person. Add 3 attributes (or fields) called first_name, middle and last_name.

Add a function called format_name() and return all 3 attributes.

(Hint: Use the same function we wrote in week 6).

Create a new instance of the Person class, set the attribute fields and then call the format_name() function using print().


Salena G.

Hi Bryce! We can schedule a short lesson about this, I can get you where you want, thanks!
Report

02/26/23

3 Answers By Expert Tutors

By:

William M.

tutor
Normally you would use __str__(self) to format a string that tells you the contents of an object Then, there is no need for the format_name(self) method but if the teacher insists, format_name(self) can just call str(self)
Report

05/31/23

Brooke R. answered • 04/05/23

Tutor
5 (8)

Princeton PhD Student | M.S. in Computer Science | Frmr SWE @ Blizzard

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.