Printing books

Report a typo

Anne is writing a program that deals with the books in a bookstore. She created a class Book and defined all the necessary attributes: author, title, price, and book_id. She would like to print out information about books in a concise and uniform way, but she doesn't know how to do that.

Help Anne by defining the right method so that she can easily print out information about her books in the following format: {title} by {author}. ${price}. [{book_id}].

For instance, if we have Book("George Orwell", "1984", 13.59, 1956789), the method should return 1984 by George Orwell. $13.59. [1956789].

Note that you do NOT need to take the input or print anything.

Tip: There are two methods that you can define, both work for this problem.

Write a program in Python 3
class Book:
def __init__(self, author, title, price, book_id):
self.author = author
self.title = title
self.price = price
self.book_id = book_id

# define the necessary method here
___

Create a free account to access the full topic