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
icon
Related questions
Question

Using the python code below. Identify the Variabale, Conditional Statement,Operators,Loops and Functions used in the code below.

PYTHON CODE:

  1. file1 = open('database.txt', 'r')
  2. count = 0
  3.    
  4. name = []
  5. age = []
  6. dep = []
  7. address = []
  8. sr_code = []
  9. status = []
  10. condition = []
  11. while True:
  12.     count += 1
  13.     line = file1.readline()
  14.     # if line is empty
  15.     # end of file is reached
  16.     if not line:
  17.         break
  18.     else:
  19.       try:
  20.         data = line.split(",")
  21.         name.append(data[0])
  22.         age.append(data[1])
  23.         dep.append(data[2])
  24.         address.append(data[3])
  25.         sr_code.append(data[4])
  26.         status.append(data[5])
  27.         condition.append(data[6])
  28.       except:
  29.         none = ""
  30. file1.close()
  31.  
  32.  
  33. def dataUp():
  34.     with open("database.txt", "w") as f:
  35.        for i in range(0,len(name)):
  36.           f.write(name[i]+"," +age[i]+","+dep[i]+","+address[i]+","+sr_code[i]+","+status[i]+","+condition[i]+"\n")
  37.        f.close()
  38.            
  39.    
  40. def add():
  41.     inp = input("Name: ")
  42.     name.append(inp)
  43.     inp = input("Age: ")
  44.     age.append(inp)
  45.     inp = input("Department: ")
  46.     dep.append(inp)
  47.     inp = input("Address: ")
  48.     address.append(inp)
  49.     inp = input("SR-Code: ")
  50.     sr_code.append(inp)
  51.     inp = input("Vaccination Status: ")
  52.     status.append(inp)
  53.     inp = input("Health condition: ")
  54.     condition.append(inp)
  55.     dataUp()
  56. def delete(sr_code):
  57.     ids = input("Enter Sr_code to DELETE:")
  58.     for i in range(0,len(name)):
  59.         if(sr_code[i]==str(ids)):
  60.             del name[i]
  61.             del age[i]
  62.             del dep[i]
  63.             del address[i]
  64.             del sr_code[i]
  65.             del status[i]
  66.             del condition[i]
  67.             dataUp()
  68.             print("Deleted Successfully!")
  69.             return
  70.     print("Sr code not found!")
  71. def update(sr_code):
  72.     ids = input("Enter Sr_code to UPDATE:")
  73.     for i in range(0,len(name)):
  74.         if(sr_code[i]==str(ids)):
  75.             name[i] = input("Enter new name: ")
  76.             age[i] = input("Enter new age: ")
  77.             dep[i] = input("Enter new department: ")
  78.             address[i] = input("Enter new address: ")
  79.             sr_code[i] = input("Enter new sr code: ")
  80.             status[i] = input("Enter new vaccination status: ")
  81.             condition[i] = input("Enter new health condition: ")
  82.             dataUp()
  83.             print("Updated Successfully!")
  84.             return
  85.     print("Sr code not found!")
  86. def vaccine(status):
  87.     vac = input("Enter vaccination status: ")
  88.     print("Name\t\t|  Age  |   Department  |   Address    |   SR-Code |  Vaccination Status  | Health Condition|")
  89.     print("-------------------------------------------------------------------------------------------------------------")
  90.     for i in range(0,len(name)):
  91.         if(status[i]==vac):
  92.            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])
  93. while True:
  94.     print("\t\t\t\t\t\tSchool College Inc")
  95.     print("\t\t\t\t\t\t  Wilson City USA")
  96.     print("\t\t\t\t\tCollege of Engineering and Fine Arts")
  97.     print("\t\t\t\t     Covid 19- Vaccination Status of the Student")
  98.     print("\t\t\t\t\t\t   S.Y. 2022-2023");
  99.     print("\t\t\t__________________________________________________________________\n");
  100.     print("COVID 19 Vaccination Monitioring System\n")
  101.     print("-------------------------------------------------------------------------------------------------------------")
  102.     print("Name\t\t|  Age  |   Department  |   Address    |   SR-Code |  Vaccination Status  | Health Condition|")
  103.     print("-------------------------------------------------------------------------------------------------------------")
  104.     for i in range(0,len(name)):
  105.         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])
  106.     print("\n|Navigation|\n")
  107.     print("[1] ADD NEW RECORD")
  108.     print("[2] DELETE A RECORD")
  109.     print("[3] UPDATE A RECORD")
  110.     print("[4] VACCINATION STATUS")
  111.     print("[5] EXIT")
  112.     print("\n_____________________________________________________________________________________________________________")
  113.     inp = input("Welcome User. Please Enter number to Continue: ")
  114.     if inp == "1":
  115.         add()
  116.         print("\nNew Data Added! Successfully")
  117.     elif inp=="2":
  118.         delete(sr_code)
  119.     elif inp == "3":
  120.         update(sr_code)
  121.     elif inp == "4":
  122.         vaccine(status)
  123.         con = input("Press anykey to continue... ")
  124.    
  125.     elif inp == "5":
  126.         break
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Intermediate SQL concepts
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education