Lists Vs Dictionary
Lists:
Lists are ordered, mutable data structure used to store a sequence of related items under a single variable name. Lists are used for effective & efficent data storing
Lists can be declared using Square Braces [ ] like this, As we know it is just similar to Arrays in other langauages, or else we can also use list() constructor For Example, Mylist = [1,”siva”,333.222,False], and the other way is mylist = list(‘banana’,’apple’,’grape’,8,9.9) both are same, both represents lists List can of any data type this differs list from Arrays.
Dictionary:
Now these are dictionaries, it is also another type of data structure
A dictionary stores data in a structured format using keys and values.
student = {
“name”: “Rahul”,
“age”: 20,
“marks”: 85
}
Here:
“name”, “age”, “marks” → keys
“Rahul”, 20, 85 → values
Dictionaries are perfect for representing real-world entities like students, employees, or products.
Designing the Mini Student Management System
Our system will support five main features:
Add student
View all students
Search student
Update marks
Delete student
Let’s build them step by step.
Step 1 — Create Storage
First, we create an empty list to store student records.
students = []
This list will act as our database.
Step 2 — Add a Student
We create a function that accepts student details and stores them.
def add_student(name, age, marks):
student = {
“name”: name,
“age”: age,
“marks”: marks
}
students.append(student)
Test
add_student(“Ravi”, 20, 78)
add_student(“Meena”, 19, 88)
print(students)
Output
[{‘name’: ‘Ravi’, ‘age’: 20, ‘marks’: 78},
{‘name’: ‘Meena’, ‘age’: 19, ‘marks’: 88}]
Get Siva Sai Vardhan’s stories in your inbox
Join Medium for free to get updates from this writer.
Each student is stored as a dictionary inside the list.
Step 3 — View Students
To display records:
def view_students():
for s in students:
print(s[“name”], s[“age”], s[“marks”])
Output
Ravi 20 78
Meena 19 88
The loop accesses each dictionary one by one.
Step 4 — Search Student
We can search by name.
def search_student(name):
for s in students:
if s[“name”] == name:
return s
return “Student not found”
Example
print(search_student(“Ravi”))
Output
{‘name’: ‘Ravi’, ‘age’: 20, ‘marks’: 78}
Step 5 — Update Marks
We modify a student’s marks.
def update_marks(name, new_marks):
for s in students:
if s[“name”] == name:
s[“marks”] = new_marks
return “Marks updated”
return “Student not found”
Step 6 — Delete Student
We remove a record from the list.
def delete_student(name):
for s in students:
if s[“name”] == name:
students.remove(s)
return “Student deleted”
return “Student not found”
Full Interactive Version
Here is a simple menu-based version:
students = []
def add_student():
name = input(“Enter name: “)
age = int(input(“Enter age: “))
marks = int(input(“Enter marks: “))
students.append({“name”: name, “age”: age, “marks”: marks})
def view_students():
for s in students:
print(s)
while True:
print(“\n1.Add 2.View 3.Exit”)
choice = input(“Enter choice: “)
if choice == “1”:
add_student()
elif choice == “2”:
view_students()
elif choice == “3”:
break
else:
print(“Invalid choice”)
This simple interface behaves like a basic software system.
Real-World Scenario
Imagine a school teacher managing 50 students. Writing and updating marks manually can be time-consuming and error-prone. A small system like this can:
Store records digitally
Update marks instantly
Search students in seconds
Remove old records easily
Although real institutions use databases and web applications, their internal logic is fundamentally the same as what we built here.




