Employee data storing
Question:
Employee data storing using python and view data using ID, and ID is generated on runtime.
Input Data:
First Name, Last Name, DOB.
this program stores the data on runtime only using list to store the data.
Program:
x=0
ll=[]
while x==0:
print("1.ADD\n2.VIEW\n3.EXIT")
n=int(input("Enter Choice:"))
e=[]
if n==1:
f=input("First Name:")
e.append(f)
l=input("Last Name:")
e.append(l)
d=input("DD-MM-YYYY:")
e.append(d)
i=f+l[0]+d[6:]
e.append(i)
ll.append(e)
elif n==2:
eid=input("Enter Employee ID:")
for j in range(0,len(ll)):
if(ll[j][3] == eid):
print("First Name:"+ll[j][0] +"\nLast Name:"+ll[j][1]+ "\nDOB:"+ll[j][2]+ "\nid:"+ll[j][3])
elif n==3:
x=1
this program stores the data in the text file .
Program:
x=0 #initialize
fi=open('employee.txt','a') #creating the file employee.txt and opening in append mode
ll=[] #list initialize
while x==0: #loop
print("1.ADD\n2.VIEW\n3.EXIT")
n=int(input("Enter Choice:"))
e=[] #list initialize
if n==1:
fi.write('----------------------------------------------\n')
f=input("First Name:")
fi.write('First Name:'+f) # write firstname in file
e.append(f) #add firstname in list
l=input("Last Name:")
e.append(l)#add lastname in list
fi.write('\nLast Name:'+l)# write lastname in file
d=input("DD-MM-YYYY:")
e.append(d)#add date in list
fi.write('\nDOB:'+d)# write DOB in file
i=f+l[0]+d[6:]# ID generation
e.append(i)#add ID in list
fi.write('\nID:'+i)# write ID in file
ll.append(e)
ff.close()
elif n==2:
eid=input("Enter Employee ID:") #employee ID for retrive data
for j in range(len(ll)):
if(ll[j][3] == eid):
print("First Name:"+ll[j][0] +"\nLast Name:"+ll[j][1]+ "\nDOB:"+ll[j][2]+ "\nid:"+ll[j][3])
elif n==3:
x=1
Employee data storing using python and view data using ID, and ID is generated on runtime.
Input Data:
First Name, Last Name, DOB.
this program stores the data on runtime only using list to store the data.
Program:
x=0
ll=[]
while x==0:
print("1.ADD\n2.VIEW\n3.EXIT")
n=int(input("Enter Choice:"))
e=[]
if n==1:
f=input("First Name:")
e.append(f)
l=input("Last Name:")
e.append(l)
d=input("DD-MM-YYYY:")
e.append(d)
i=f+l[0]+d[6:]
e.append(i)
ll.append(e)
elif n==2:
eid=input("Enter Employee ID:")
for j in range(0,len(ll)):
if(ll[j][3] == eid):
print("First Name:"+ll[j][0] +"\nLast Name:"+ll[j][1]+ "\nDOB:"+ll[j][2]+ "\nid:"+ll[j][3])
elif n==3:
x=1
this program stores the data in the text file .
Program:
x=0 #initialize
fi=open('employee.txt','a') #creating the file employee.txt and opening in append mode
ll=[] #list initialize
while x==0: #loop
print("1.ADD\n2.VIEW\n3.EXIT")
n=int(input("Enter Choice:"))
e=[] #list initialize
if n==1:
fi.write('----------------------------------------------\n')
f=input("First Name:")
fi.write('First Name:'+f) # write firstname in file
e.append(f) #add firstname in list
l=input("Last Name:")
e.append(l)#add lastname in list
fi.write('\nLast Name:'+l)# write lastname in file
d=input("DD-MM-YYYY:")
e.append(d)#add date in list
fi.write('\nDOB:'+d)# write DOB in file
i=f+l[0]+d[6:]# ID generation
e.append(i)#add ID in list
fi.write('\nID:'+i)# write ID in file
ll.append(e)
ff.close()
elif n==2:
eid=input("Enter Employee ID:") #employee ID for retrive data
for j in range(len(ll)):
if(ll[j][3] == eid):
print("First Name:"+ll[j][0] +"\nLast Name:"+ll[j][1]+ "\nDOB:"+ll[j][2]+ "\nid:"+ll[j][3])
elif n==3:
x=1
Comments
Post a Comment