Using the python code below. Identify the following: A. Loop B. Variable C. Conditional Statements D. Operators E. FUnctions

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Using the python code below. Identify the following:

A. Loop

B. Variable

C. Conditional Statements

D. Operators

E. FUnctions

 

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
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY