-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path04-code.py
More file actions
29 lines (22 loc) · 901 Bytes
/
04-code.py
File metadata and controls
29 lines (22 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Initialize an empty dictionary
student_records = {}
print("--- Data Entry Mode ---")
while True:
name = input("Enter child's name (or type 'done' to stop): ").strip()
# Check if the user wants to stop entering data
if name.lower() == 'done':
break
marks = input(f"Enter marks for {name}: ")
# Store the data in the dictionary
student_records[name] = marks
print(f"Added: {name} with {marks} marks.\n")
print("\n--- Search Mode ---")
while True:
search_query = input("Enter name to search (or type 'exit' to quit): ").strip()
if search_query.lower() == 'exit':
break
# Check if the name exists in our dictionary
if search_query in student_records:
print(f"Result: {search_query} has {student_records[search_query]} marks.")
else:
print(f"Error: '{search_query}' not found in records.")