Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Internet & the Web (https://www.askmehelpdesk.com/forumdisplay.php?f=177)
-   -   How to create FindStuMaxBorrowedBooks(lib) function in python? (https://www.askmehelpdesk.com/showthread.php?t=839413)

  • Jun 19, 2018, 06:25 PM
    LLMH
    How to create FindStuMaxBorrowedBooks(lib) function in python?
    Function FindStuMaxBorrowedBooks(lib) that will find the students borrowing the most books from the library database. The function should not print out any message on screen but return all the information through the return statement. If there are more than one student who borrows the same maximum number of books, then your code should return all of them.
    In the main program, define a dictionary lib (as shown below) that stores the list of all student identities who borrow books from the library. Call FindStuMaxBorrowedBooks to get the student(s) who borrow the most books. Then, print your result. You should print the student id, and the book(s) borrowed.
    One simple example is illustrated below.
    Lib:
    {0: {'Book 2222', 'Book 1249', 'Book 9228'},
    8: {'Book 2343', 'Book 4354'},
    2: {'Book 3433', 'Book 3545', 'Book 3434'},
    5: {'Book 2321', 'Book 2357'}}
    Output:
    The following students borrowed the most books, i.e. 3 books
    Student ID 0 borrowed:
    {'Book 2222', 'Book 1249', 'Book 9228'}
    Student ID 2 borrowed:
    {'Book 3433', 'Book 3434', 'Book 3545'}

  • All times are GMT -7. The time now is 08:39 PM.