Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull Request: Merging 'rename_organise' into 'master' branch #1934

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import pickle
def bdelete():
# Opening a file & loading it
with open("studrec.dat") as F:
stud = pickle.load(F)
print(stud)
# Deleting the Roll no. entered by user
rno = int(input("Enter the Roll no. to be deleted: "))
with open("studrec.dat") as F:
rec = []
for i in stud:
if i[0] == rno:
continue
rec.append(i)
pickle.dump(rec, F)
bdelete()
import pickle


def bdelete():
# Opening a file & loading it
with open("studrec.dat") as F:
stud = pickle.load(F)
print(stud)

# Deleting the Roll no. entered by user
rno = int(input("Enter the Roll no. to be deleted: "))
with open("studrec.dat") as F:
rec = []
for i in stud:
if i[0] == rno:
continue
rec.append(i)
pickle.dump(rec, F)


bdelete()
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import pickle
def binary_read():
with open("studrec.dat") as b:
stud = pickle.load(b)
print(stud)
# prints the whole record in nested list format
print("contents of binary file")
for ch in stud:
print(ch) # prints one of the chosen rec in list
rno = ch[0]
rname = ch[1] # due to unpacking the val not printed in list format
rmark = ch[2]
print(rno, rname, rmark, end="\t")
binary_read()
import pickle


def binary_read():
with open("studrec.dat") as b:
stud = pickle.load(b)
print(stud)

# prints the whole record in nested list format
print("contents of binary file")

for ch in stud:

print(ch) # prints one of the chosen rec in list

rno = ch[0]
rname = ch[1] # due to unpacking the val not printed in list format
rmark = ch[2]

print(rno, rname, rmark, end="\t")


binary_read()
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# Updating records in a binary file
import pickle
def update():
F = open("class.dat", "rb+")
S = pickle.load(F)
found = 0
rno = int(input("enter the roll number you want to update"))
for i in S:
if rno == i[0]:
print("the currrent name is", i[1])
i[1] = input("enter the new name")
found = 1
break
if found == 0:
print("Record not found")
else:
F.seek(0)
pickle.dump(S, F)
F.close()
update()
F = open("class.dat", "rb")
val = pickle.load(F)
print(val)
F.close()
# Updating records in a binary file

import pickle


def update():
F = open("class.dat", "rb+")
S = pickle.load(F)
found = 0
rno = int(input("enter the roll number you want to update"))
for i in S:
if rno == i[0]:
print("the currrent name is", i[1])
i[1] = input("enter the new name")
found = 1
break

if found == 0:
print("Record not found")

else:
F.seek(0)
pickle.dump(S, F)

F.close()


update()

F = open("class.dat", "rb")
val = pickle.load(F)
print(val)
F.close()
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# updating records in a bnary file
import pickle
def update():
File = open("studrec.dat", "rb+")
value = pickle.load(File)
found = 0
roll = int(input("Enter the roll number of the record"))
for i in value:
if roll == i[0]:
print("current name", i[1])
print("current marks", i[2])
i[1] = input("Enter the new name")
i[2] = int(input("Enter the new marks"))
found = 1
if found == 0:
print("Record not found")
else:
pickle.dump(value, File)
File.seek(0)
newval = pickle.load(File)
print(newval)
File.close()
update()
# updating records in a bnary file

import pickle


def update():
File = open("studrec.dat", "rb+")
value = pickle.load(File)
found = 0
roll = int(input("Enter the roll number of the record"))
for i in value:
if roll == i[0]:
print("current name", i[1])
print("current marks", i[2])
i[1] = input("Enter the new name")
i[2] = int(input("Enter the new marks"))
found = 1

if found == 0:
print("Record not found")

else:
pickle.dump(value, File)
File.seek(0)
newval = pickle.load(File)
print(newval)

File.close()


update()
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
"""Amit is a monitor of class XII-A and he stored the record of all
the students of his class in a file named “class.dat”.
Structure of record is [roll number, name, percentage]. His computer
teacher has assigned the following duty to Amit
Write a function remcount( ) to count the number of students who need
remedial class (student who scored less than 40 percent)
"""
# also find no. of children who got top marks
import pickle
F = open("class.dat", "ab")
list = [
[1, "Ramya", 30],
[2, "vaishnavi", 60],
[3, "anuya", 40],
[4, "kamala", 30],
[5, "anuraag", 10],
[6, "Reshi", 77],
[7, "Biancaa.R", 100],
[8, "sandhya", 65],
]
pickle.dump(list, F)
F.close()
def remcount():
F = open("class.dat", "rb")
val = pickle.load(F)
count = 0
for i in val:
if i[2] <= 40:
print(i, "eligible for remedial")
count += 1
print("the total number of students are", count)
F.close()
remcount()
def firstmark():
F = open("class.dat", "rb")
val = pickle.load(F)
main = []
count = 0
for i in val:
data = i[2]
main.append(data)
top = max(main)
print(top, "is the first mark")
F.seek(0)
for i in val:
if top == i[2]:
print(i)
print("congrats")
count += 1
print("the total number of students who secured top marks are", count)
F.close()
firstmark()
F = open("class.dat", "rb")
val = pickle.load(F)
print(val)
F.close()
"""Amit is a monitor of class XII-A and he stored the record of all
the students of his class in a file named “class.dat”.
Structure of record is [roll number, name, percentage]. His computer
teacher has assigned the following duty to Amit

Write a function remcount( ) to count the number of students who need
remedial class (student who scored less than 40 percent)


"""
# also find no. of children who got top marks

import pickle

F = open("class.dat", "ab")
list = [
[1, "Ramya", 30],
[2, "vaishnavi", 60],
[3, "anuya", 40],
[4, "kamala", 30],
[5, "anuraag", 10],
[6, "Reshi", 77],
[7, "Biancaa.R", 100],
[8, "sandhya", 65],
]


pickle.dump(list, F)
F.close()


def remcount():
F = open("class.dat", "rb")
val = pickle.load(F)
count = 0

for i in val:
if i[2] <= 40:
print(i, "eligible for remedial")
count += 1
print("the total number of students are", count)
F.close()


remcount()


def firstmark():
F = open("class.dat", "rb")
val = pickle.load(F)
main = []
count = 0

for i in val:
data = i[2]
main.append(data)

top = max(main)
print(top, "is the first mark")

F.seek(0)
for i in val:
if top == i[2]:
print(i)
print("congrats")
count += 1

print("the total number of students who secured top marks are", count)
F.close()


firstmark()

F = open("class.dat", "rb")
val = pickle.load(F)
print(val)
F.close()
Loading