Using the python code below. Identify the Variabale, Conditional Statement,Operators,Loops and Functions used in the code below. PYTHON CODE: file1 = open('database.txt', 'r') count = 0 name = [] age = [] dep = [] address = [] sr_code = [] status = [] condition = [] while True:
Using the python code below. Identify the Variabale, Conditional Statement,Operators,Loops and Functions used in the code below. PYTHON CODE: file1 = open('database.txt', 'r') count = 0 name = [] age = [] dep = [] address = [] sr_code = [] status = [] condition = [] while True:
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Using the python code below. Identify the Variabale, Conditional Statement,Operators,Loops and Functions used in the code below.
PYTHON CODE:
-
file1 = open('database.txt', 'r')
-
count = 0
-
-
name = []
-
age = []
-
dep = []
-
address = []
-
sr_code = []
-
status = []
-
condition = []
-
while True:
-
count += 1
-
line = file1.readline()
-
# if line is empty
-
# end of file is reached
-
if not line:
-
break
-
else:
-
try:
-
data = line.split(",")
-
name.append(data[0])
-
age.append(data[1])
-
dep.append(data[2])
-
address.append(data[3])
-
sr_code.append(data[4])
-
status.append(data[5])
-
condition.append(data[6])
-
except:
-
none = ""
-
file1.close()
-
-
-
def dataUp():
-
with open("database.txt", "w") as f:
-
for i in range(0,len(name)):
-
f.write(name[i]+"," +age[i]+","+dep[i]+","+address[i]+","+sr_code[i]+","+status[i]+","+condition[i]+"\n")
-
f.close()
-
-
-
def add():
-
inp = input("Name: ")
-
name.append(inp)
-
inp = input("Age: ")
-
age.append(inp)
-
inp = input("Department: ")
-
dep.append(inp)
-
inp = input("Address: ")
-
address.append(inp)
-
inp = input("SR-Code: ")
-
sr_code.append(inp)
-
inp = input("Vaccination Status: ")
-
status.append(inp)
-
inp = input("Health condition: ")
-
condition.append(inp)
-
dataUp()
-
def delete(sr_code):
-
ids = input("Enter Sr_code to DELETE:")
-
for i in range(0,len(name)):
-
if(sr_code[i]==str(ids)):
-
del name[i]
-
del age[i]
-
del dep[i]
-
del address[i]
-
del sr_code[i]
-
del status[i]
-
del condition[i]
-
dataUp()
-
print("Deleted Successfully!")
-
return
-
print("Sr code not found!")
-
def update(sr_code):
-
ids = input("Enter Sr_code to UPDATE:")
-
for i in range(0,len(name)):
-
if(sr_code[i]==str(ids)):
-
name[i] = input("Enter new name: ")
-
age[i] = input("Enter new age: ")
-
dep[i] = input("Enter new department: ")
-
address[i] = input("Enter new address: ")
-
sr_code[i] = input("Enter new sr code: ")
-
status[i] = input("Enter new vaccination status: ")
-
condition[i] = input("Enter new health condition: ")
-
dataUp()
-
print("Updated Successfully!")
-
return
-
print("Sr code not found!")
-
def vaccine(status):
-
vac = input("Enter vaccination status: ")
-
print("Name\t\t| Age | Department | Address | SR-Code | Vaccination Status | Health Condition|")
-
print("-------------------------------------------------------------------------------------------------------------")
-
for i in range(0,len(name)):
-
if(status[i]==vac):
-
print(name[i]+"\t\t"+age[i]+"\t"+dep[i]+"\t\t"+address[i]+"\t\t"+sr_code[i]+"\t\t"+status[i]+"\t\t"+condition[i])
-
while True:
-
print("\t\t\t\t\t\tSchool College Inc")
-
print("\t\t\t\t\t\t Wilson City USA")
-
print("\t\t\t\t\tCollege of Engineering and Fine Arts")
-
print("\t\t\t\t Covid 19- Vaccination Status of the Student")
-
print("\t\t\t\t\t\t S.Y. 2022-2023");
-
print("\t\t\t__________________________________________________________________\n");
-
print("COVID 19 Vaccination Monitioring System\n")
-
print("-------------------------------------------------------------------------------------------------------------")
-
print("Name\t\t| Age | Department | Address | SR-Code | Vaccination Status | Health Condition|")
-
print("-------------------------------------------------------------------------------------------------------------")
-
for i in range(0,len(name)):
-
print(name[i]+"\t\t"+age[i]+"\t"+dep[i]+"\t\t"+address[i]+"\t\t"+sr_code[i]+"\t\t"+status[i]+"\t\t"+condition[i])
-
print("\n|Navigation|\n")
-
print("[1] ADD NEW RECORD")
-
print("[2] DELETE A RECORD")
-
print("[3] UPDATE A RECORD")
-
print("[4] VACCINATION STATUS")
-
print("[5] EXIT")
-
print("\n_____________________________________________________________________________________________________________")
-
inp = input("Welcome User. Please Enter number to Continue: ")
-
if inp == "1":
-
add()
-
print("\nNew Data Added! Successfully")
-
elif inp=="2":
-
delete(sr_code)
-
elif inp == "3":
-
update(sr_code)
-
elif inp == "4":
-
vaccine(status)
-
con = input("Press anykey to continue... ")
-
-
elif inp == "5":
-
break
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education