Skip to content

Commit 64eef66

Browse files
formatted
1 parent 9c54b37 commit 64eef66

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

1 File handle/File handle binary/question 1 (elegible for remedial, top marks).py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
We have to find weak students and bright students.
1111
"""
1212

13-
1413
## Find bright students and weak students
1514

1615
from dotenv import load_dotenv
@@ -35,7 +34,6 @@ def remcount():
3534
val = pickle.load(F)
3635
count = 0
3736
weak_students = []
38-
3937

4038
for student in val:
4139
if student[2] <= 40:
@@ -45,9 +43,9 @@ def remcount():
4543
print(f"the total number of weak students are {count}")
4644
print(f"The weak students are {weak_students}")
4745

48-
4946
# ! highest marks is the key here first marks
50-
47+
48+
5149
def firstmark():
5250
with open(student_record, "rb") as F:
5351
val = pickle.load(F)
@@ -63,5 +61,6 @@ def firstmark():
6361
count += 1
6462
print("The total number of students who secured top marks are", count)
6563

64+
6665
remcount()
67-
firstmark()
66+
firstmark()

1 File handle/File handle binary/search record in binary file.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import pickle
44
from dotenv import load_dotenv
55

6+
67
def search():
78
with open("student_records.pkl", "rb") as F:
89
# your file path will be different
9-
search = True
10+
search = True
1011
rno = int(input("Enter the roll number of the student"))
1112

1213
for i in pickle.load(F):

1 File handle/File handle binary/update2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
import pickle
44
import os
55
from dotenv import load_dotenv
6+
67
base = os.path.dirname(__file__)
78
load_dotenv(os.path.join(base, ".env"))
89
student_record = os.getenv("STUDENTS_RECORD_FILE")
910

11+
1012
def update():
1113
with open(student_record, "rb") as F:
1214
S = pickle.load(F)
@@ -23,9 +25,8 @@ def update():
2325
if found:
2426
print("Record not found")
2527

26-
2728
with open(student_record, "wb") as F:
2829
pickle.dump(S, F)
2930

3031

31-
update()
32+
update()

0 commit comments

Comments
 (0)