forked from AEC-Tech/Python-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq14.py
36 lines (33 loc) · 822 Bytes
/
q14.py
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
30
31
32
33
34
35
36
import pickle
def createFile():
f = open("emp.dat","ab")
n = int(input("How many employees : "))
for i in range(n):
en = int(input("Enter employee id : "))
name = input("Enter name : ")
sal = int(input("Enter Salary : "))
e ={"Eid":en,"Name":name,"Salary":sal}
pickle.dump(e,f)
f.close()
def showFile():
f = open("emp.dat","rb")
try:
while True:
e = pickle.load(f)
print(e)
except:
f.close()
def showSalary():
f = open("emp.dat","rb")
try:
while True:
e = pickle.load(f)
if e['Salary'] >= 25000:
print(e)
except:
f.close()
createFile()
print("List of All Employees ")
showFile()
print("list of Employees earning more than 250000")
showSalary()