Question: Python question: Write a class called 'RockGuitars()' that has attributes: 'guitarist' and 'guitar'. It has a constructor with three parameters, self, guitarist and guitar. The

Python question:

Write a class called 'RockGuitars()' that has attributes: 'guitarist' and 'guitar'. It has aconstructor with three parameters, self, guitarist and guitar. The default value of guitarist and guitar should be empty string. The class should have __str__ method to return a string for output using this format: "{:<20s} {:<20s}". Lastly, it has the following method to add guitarist and guitar:

add_entry(guitarist, guitar): both 'guitarist' and 'guitar' are string with default value of ""

Example:

g_obj = RockGuitars()

g_obj.add_entry("Jimmy Page", "Gibson Les Paul Standard")

f_obj = RockGuitars()

f_obj.add_entry("Angus Young", "Jaydee SG")

print(g)

print(f)

Jimmy Page Gibson Les Paul Standard Angus Young Jaydee SG

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!