Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
108 views

Module 5 Assignment: in A Bookstore, Somewhere in India

The document describes an assignment to create a Python program that connects to a SQLite database of book titles, authors, and prices. Part 1 involves writing a script to create the required database and programmatically add data using INSERT queries. Part 2 involves writing a script that takes user input for a book title and quantity, fetches the price from the database using a SELECT query, calculates the total amount, and displays it. The submission should include code files for creating and populating the database, a main script to get user input and display output, and the database file. The assignment evaluates creating a database using INSERT and executing SQL queries through Python.

Uploaded by

Ashish yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views

Module 5 Assignment: in A Bookstore, Somewhere in India

The document describes an assignment to create a Python program that connects to a SQLite database of book titles, authors, and prices. Part 1 involves writing a script to create the required database and programmatically add data using INSERT queries. Part 2 involves writing a script that takes user input for a book title and quantity, fetches the price from the database using a SELECT query, calculates the total amount, and displays it. The submission should include code files for creating and populating the database, a main script to get user input and display output, and the database file. The assignment evaluates creating a database using INSERT and executing SQL queries through Python.

Uploaded by

Ashish yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Module 5 Assignment

Introduction
In this assignment, you are required to apply your knowledge of connecting a SQLite
database to a Python program. Read the scenario below and then respond to the problem
statement described.

Scenario
In a bookstore, somewhere in India.
Pi: Hi, do you have Think Python?
Store Assistant: Let me check, Sir.
(The assistant checks on his computer. This is what his screen looks like.)

Store Assistant: Yes Sir, we have it in stock. It costs Rs. 475. Would you like to take it?
Pi: Yes please. And give me two copies.
Store Assistant: Sure. Anything else, Sir?
Pi: Nope thanks. What's the total?
(The assistant now enters the number of copies on his computer. This is what his screen looks like.)

Problem Statement
Assume that you have to create such an application for maintaining a database of book titles
and their costs.

Part 1: Write the script to create the required database and add data programmatically by
using the Insert query.

Part 2: Write a Python script connecting to the database created that has the following
features:

Programming with Python


Module 5 Assignment

• A books table having the title, author, and price as fields.


• Accept input from the user for the title and quantity purchased by the customer.
• Fetch the price from the table by executing the Select query.
• Calculate the total amount and display it.

Assignment Submission
Your submission should have fully functional code with:

1. One script file containing the code for create the required database and add data
programmatically by using the Insert query.
2. One script file with the main code which takes the book title (of a book you have
already entered into the database) and number of copies as input and displays the
output.
3. One database file containing data for the book id, title, author and price.

Learning outcomes being evaluated


• Create a SQLite database by executing the INSERT query.
• Execute SQL Queries through Python.

Programming with Python

You might also like