PLEASE HELP ME COMPLETE THESE 4 ACTIVITIES USE Python Lists Python…
Question Answered step-by-step PLEASE HELP ME COMPLETE THESE 4 ACTIVITIES USE Python Lists Python… PLEASE HELP ME COMPLETE THESE 4 ACTIVITIESUSEPython ListsPython DictionaryClasses and ObjectsActivity 1: Create a LibraryAdmin ClassMake a class LibraryAdmin. Add a constructor (__init()__ function) to the class. This constructor must initialise the following variables:list_books: A list to store the list of books. Initialise this list with the values passed whenever a new object of LibraryAdmin class is created.borrowers_dict: A dictionary to keep track of books lent to another user. Keep this dictionary empty. [ ] # Make class LibraryAdmin and add constructor Activity 2: Add FunctionsAdd the following four functions inside the LibraryAdmin class:The display_books() function: Display all the books stored in the list_books list using for loop.The lend_book() function: This function takes two parameters; book and borrower. The book parameter holds the name of the book and the borrower parameter holds the name of the user to whom the book is to be lent.Inside this function, check whether the book is already present in the borrowers_dict dictionary or not.If the book is not in borrowers_dict{}, update this dictionary using update() function. Pass the name of the book i.e. book variable as key and name of the user i.e. borrower variable as its value to the update() function.If the book exists in borrowers_dict{}, this means that this book is already issued by another user. Thus, display the message “Sorry, this book is already issued”.The add_book() function: This function takes a parameter book which holds the name of the book to be added to the library. Use the append() function to add the book to the list_books list. Also, display a message “Book has been successfully added in the Library”.The collect_book() function: This function takes a parameter book which holds the name of the book to be removed from the borrowers_dict dictionary. Use the pop() function of the Python dictionary to remove the book from the borrowers_dict dictionary. Also, display a message “Book is successfully removed from the Library”.Note: Do not forget to keep self keyword as the first argument or parameter in all the class functions. [ ] # Make Functions inside ‘Library’ class. Activity 3: Create an Object of LibraryAdminMake an object of LibraryAdmin class and pass a list as a parameter. This list consists of names of books that initially exist in your library. [ ] # Create an object of Library class and pass a list of books as a parameter Activity 4: Call the FunctionsMake an infinite while loop. Inside this while loop perform the following tasks:Display the following list of choices:Enter : 1 to DISPLAY books 2 to LEND a book 3 to ADD a book 4 to COLLECT a book 9 to QUIT the applicationTake user input and store it in a variable user_choice. Check whether the user entered any input other than 1, 2, 3, 4, or 9. If yes, then display a message “Please enter a valid option” and keep on asking for user input unless the user enters a valid choice.Now using the if-elif-else statement, check user input and call the corresponding functions using the object of the LibraryAdmin class.If user_choice==1, call the display_books() functionIf user_choice==2, ask the user to enter the name of the book which is to be lent and the name of the borrower and pass them as parameters to the lend_book() function.If user_choice==3, ask the user to enter the name of the book which is to be added and pass this as a parameter to the add_book() function.If user_choice==4, ask the user to enter the name of the book which is to be collected back and pass this as a parameter to the collect_book() function.If user_choice==9, break the infinite while loop using the break statement.Note: Call all the four functions using the object of LibraryAdmin class only. [ ] # Call the functions Computer Science Engineering & Technology Python Programming ENGINEERIN EGD203 Share QuestionEmailCopy link Comments (0)


