My Library

For this challenge you will work for the librarian who needs a computer program to help pupils find out where books can be found in the library.

MyLibrary

The library contains nine bookshleves labelled from A to I. Each bookshelf specialises in one genre. For instance, bookshelf A is for comedy fiction books.

Below is the list of bookshelves and genres:
MyLibrary-bookshelves

Your Task:


Your task is to write a computer program that asks the user if they are looking for a fiction or a non-fiction book. Based on the user answer the program will ask the user to choose the genre from a list of available genres. Finally the program will return the location (A to I) of books of this genre.

Learning Objectives


By completing this challenge you will use selection statements (if, elif and else). You will also use nested constructs by having if statements within if statements.

When using if statements you have to indent your code as follows:
code-indentation

Let’s get coding


We have started the code for you but this code is incomplete: Can you complete the code to cater for all nine genres?

Extension Task:


The Science and Technology section of the library is growing. The librarian decides to have five sub-sections for this section as follows:

    H1: Biology Books
    H2: Physics Books
    H3: Chemistry Books
    H4: Computer Science Books
    H5: Design & Technology Books

Extend your code further to include these five subcategories in your algorithm. (See below for a full list of all the required genres.)

MyLibrary-bookshelves-2

To do so you will need to indent your code further as follows. This is called nested indentation:
code-nested-indentation

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 4.9 / 5. Vote count: 13

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,