Problem Statement:

In this assignment, you will write a simple python application to simulate a mini book shop check out system. The purpose of this assignment is to gain experience in python's for loop and sequence.

Lab Scenario:

  • You are given a list containing the title and price of the book. The list named books is provided in the template file.
  • User will first be prompted to enter the number of the book s/he wants to add to the cart. Let's say the name of the variable is total_count (given in the template file)
  • A while loop will run through the program total_count number of times to add the required number of books to user checklist.
  • User will be displayed with the books list and then prompt to enter the title of the book for purchasing. Hint: How to convert a list to a string for nice display?
  • The list is defined as follows:
    • Each item of the list is a string.
    • Title of the book and price are separated by a colon (':').
    • You need to separate the title and the price of the book by (':'). Hint: Remember how you split a string?
  • You are expected to use for loop to iterate through each item in the list, separate the title and price. The program will match the user input with the title in the list.
  • If the user input matches with one of the titles in books list then that item will be added to user checklist. Otherwise, no book will be added. Hint: Use a comparison operator to see if the user input matches with any title in the books list.
  • For this lab, the program needs to be case sensitive. For example: user can enter the name in all lowercase but the program will still find the name of the book if present in the list. Hint: string.lower() and string.upper() are two methods that can be used.
  • Test the application by considering some possible I/O

Sample I/O: (Sample run )

*********** Welcome to mini book store ***********
How many books to checkout? 2
******* List of Books *******

Girl With No Name:14.88
Despicable Me:12.99
Journey To The Moon:10.99
The Calculating Stars:20.0

Enter book title to add to cart: 14.88
Book not found

******* List of Books *******

Girl With No Name:14.88
Despicable Me:12.99
Journey To The Moon:10.99
The Calculating Stars:20.0

Enter book title to add to cart: Girl with no name
Girl With No Name:$14.88 added to your cart

******* List of Books *******

Girl With No Name:14.88
Despicable Me:12.99
Journey To The Moon:10.99
The Calculating Stars:20.0

Enter book title to add to cart: despicable me
Despicable Me:$12.99 added to your cart

Your cart:
Girl With No Name:$14.88
Despicable Me:$12.99
------------------------
Your total: $27.87
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.