Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions

Question

=+ d. a professor deciding how much to prepare for class

Answered: 1 week ago

Question

=+ a. a family deciding whether to buy a new car

Answered: 1 week ago