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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started