0

how to create book class in python?

Design a ‘book’ class with title, author, publisher, price and author’s royalty as instance variables. Provide getter and setter properties for all variables. Also define a method royalty() to calculate royalty amount author can expect to receive the following royalties:10% of the retail price on the first 500 copies; 12.5% for the next 1,000 copies sold, then 15% for all further copies sold.

26th Jun 2019, 8:49 AM
yash gupta
yash gupta - avatar
1 Antwort
+ 2
class Book: def __init__(self, author, title, book_id): self.author = author self.title = title self.book_id = book_id def __str__(self): return 'Book(author, title, book_id)' def __repr__(self): return 'Book(author, title, book_id)' def __eq__(self, other): #Not sure if this is the right approach for title in Book: for title in Book: if title == title: if author == author: if book_id == book_id: return True
8th Jul 2022, 6:25 AM
Jibran Abdul Jabbar
Jibran Abdul Jabbar - avatar