Head office, Rana Pratap Bagh, Delhi011 2721 1512+91 97116 99511

Science project idea

Python student record manager saved in a JSON file

Records of students are stored as nested data in a JSON file and can be added, searched, updated and deleted. It is a small version of how real databases and apps keep data.

What it shows

Records of students are stored as nested data in a JSON file and can be added, searched, updated and deleted. It is a small version of how real databases and apps keep data.

The science

JSON is a text format for storing dictionaries and lists, which Python reads with json.load and writes with json.dump. Each student is a dictionary stored under a roll number key. The four basic operations on stored data are create, read, update and delete, often called CRUD, and almost every app is built on them.

Materials

Cost: free. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.

  • A computer, laptop or phone with a browser (free)
  • Python 3 with IDLE, or the free Thonny editor, or an online Python runner (all free)
  • Made-up student data only, with no real names or numbers
  • A notebook and a pencil

Safety

This project uses safe, everyday materials. Still, read the rules below with a parent before you start.

Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.

All the safety rules

Step by step

8 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.

  1. Create records.py and write import json and import os, then define FILE = "students.json".

  2. Write def load(): returning json.load(f) from open(FILE) if os.path.exists(FILE), otherwise an empty dictionary {}.

  3. Write def save(data): with open(FILE, "w") as f: and json.dump(data, f, indent=2).

  4. Write add(data): ask for roll, name and marks, then data[roll] = {"name": name, "marks": int(marks)} and save(data).

  5. Write search(data): ask for a roll and print data.get(roll, "Not found").

  6. Write update(data) to change marks if roll in data, and delete(data) using del data[roll] after checking.

  7. Write a menu loop with choices 1 Add, 2 Search, 3 Update, 4 Delete, 5 List, 6 Quit, where List prints every record with a for loop over data.items().

  8. Add five made-up students, quit, run again and open students.json in Notepad to see the stored records.

What you should see

Records can be added, found, changed and deleted from a menu, and they remain in students.json after the program is closed.

Viva questions

A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.

1What is JSON?

A text format for storing dictionaries and lists.

2What does CRUD stand for?

Create, read, update and delete.

3Why use the roll number as the key?

It is unique, so each student has exactly one record.

4Why use get() for searching?

It gives a default message instead of an error if the key is missing.

Free ebook: Viva Questions for Science Projects

Take it further

Add a report that prints the class topper and the average using max with a key function.

Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.

Free ebooks for this project

WhatsApp us