Answered step by step
Verified Expert Solution
Question
1 Approved Answer
solve this in pycharm please and with a picture for the output Q1. Write a class Library which has the following attributes: Book title Book
solve this in pycharm please and with a picture for the output
Q1. Write a class Library which has the following attributes: Book title Book author Year: this variable store the year of publishing. Make this variable private. Available: Boolean variable that indicate if the book is available or not Total number of books: this variable store the total number of books in the library Constructor: initializes the book title, author, and year. If the year is less than 1990 or greater than the current year (use datetime module to get the current year), then print an error message. The constructor also increases the number of total books by 1 and set available to True. Set and get methods to year. Write a test code. Create the following objects (instance) of type library: Title: Harry potter, author: J. K. Rolling, Year: 1997 Title: The Da Vinci Code, author: Dan Brown, Year: 2003 Title: Life of PI, author: Yann Martel, Year: 2001 Add all the books to a list. Then print a menu that allow users to borrow a book, or search a book by year. If the user chose to borrow a book, then only print the books that are available. Make sure to change the book availability to False if a user borrowed it. If all the books are borrowed, then, print "No books are available at the moment". Refer to the sample output. Note: To get current year: import datetime current year = datetime.datetime.now(.year Sample output: ===== Welcome to the Library we have a total of 3 books ==== What would you like to do? 1-Borrow a book 2-Search a book by year Enter your choice. - I to stop: 3 Invalid choice What would you like to do? 1-Borrow a book 2-Search a book by year Enter your choice. -1 to stop: 2 Enter a year: 2003 Books published in 2003 are: Title: The Da Vinci Code Author: Dan Brown Year:2003 What would you like to do? 1-Borrow a book 2-Search a book by year Enter your choice. -1 to stop: 1 Choose a book: 1. Harry potter 2- The Da Vinci Code 3- The life of P1 You got the book! What would you like to do? 1-Borrow a book 2-Search a book by year Enter your choice. -1 to stop: 1 Choose a book: 2- The Da Vinci Code 3- The life of P1 You got the book! What would you like to do? 1-Borrow a book 2-Search a book by year Enter your choice. - 1 to stop: 1 Choose a book: 2- The Da Vinci Code 2 You got the book! What would you like to do? 1-Borrow a book 2-Search a book by year Enter your choice. -1 to stop: 1 No books are available at the moment! 1 3 What would you like to do? 1-Borrow a book 2-Search a book by year Enter your choice. I to stop: -1 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