Objectives

Students will be able to:

  • Write code to process an array-based database.

Developing a cool database in Python

Let's look at how to set up a database using arrays in Python.

Task Files

Download these files and save them in a project folder:

data file

starter code

Use the task files and copy what you see in this video:

   Challenge 1

Create a program that will ask the user to enter the words input or output only and it will calculate and display the average price of all of those kinds of devices stored in the arrays.

Remember to validate the user entry!

Now watch this video for a way to search a string for a substring in Python:

    Challenge 2 - Wildcards

Develop a computer program that:

  1. displays the input and output devices.
  2. asks the user to enter a model or model number.
  3. if the number in stock of the model is 0, a message OUT OF STOCK!! appears.
  4. else the price of the item is displayed and the number in stock is updated and displayed.
  5. steps 1-4 are repeated infinitely... or until the user closes the program hint:wrap all of your code in a while True: loop...

    Challenge 3 - Very Tricky!

If a user enters a model number that does not exist, the program asks the user if (s)he wants to enter new data into the database. If the answer is Y, new data is appended to the database tables.

Food For Thought

There are many ways to create a database in a computer program. This method is very basic because when we close the program, we lose all of the changes that were made to the arrays.

Homework




essential vocabulary

database querycriteriaimport evidence table integer screenshot record text ascending field double descending data type Yes/No


SUBSCRIBE

Join my mailing list to receive updates on the latest blog posts and other things.