
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
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 stepSolved 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
- T9arrow_forwardWhich statement is used to create a user-defined data type?a. Declareb. Define c. Structured. UserTypearrow_forwardpython function that creates and saves data in a file. the saved data represents exam grades. in the function , you will create n random numbers in the range 1-100, where n is the number of students. The function can be called as follows: createFile(filename, n) main function, in which the user inputs the file name and the number of students, then the main calls function createfile. the main should preform validation for n (should be > 0), and the filename(should end with .txt)arrow_forward
- createDatabaseOfProfiles(String filename) This method creates and populates the database array with the profiles from the input file (profile.txt) filename parameter. Each profile includes a persons' name and two DNA sequences. 1. Reads the number of profiles from the input file AND create the database array to hold that number profiles. 2. Reads the profiles from the input file. 3. For each person in the file 1. creates a Profile object with the information from file (see input file format below). 2. insert the newly created profile into the next position in the database array (instance variable).arrow_forwardGiven: string s; int first, last; Write code to repeatedly validate that first is less than last and both first and last are valid indexes of the string s. Then print all characters of the string s from index first to last inclusive. Example Output 1 Enter a string and two indexes: Queensborough 25 eens Example Output 2 Enter a string and two indexes: Science 2 10 Enter a string and two indexes: Science -15 Enter a string and two indexes: Science 2 4 ienarrow_forwardIn C++, how do you encrypt one character in a file read into the code?arrow_forward
- Python 3 Given that a variable named pathName contains a string describing a directory path, write a single Python statement that will store the names of all files and subdirectories in that path in a List structure named contents. DO NOT traverse the path/directory. You are only interested in the immediate path and its contents. You may assume that any necessary import statements already exist.arrow_forwardPythonarrow_forwardPython 3 NO IMPORT PICKLE Please check the picture and add one more function(def) to display menu and fix the error in the code. Write a program that keeps names and email addresses in a dictionary as key-value pairs. You Must create and use at least 5 meaningful functions. A function to display a menu A function to look up a person’s email address A function to add a new name and email address A function to change an email address A function to delete a name and email address. This is the Required Output example: Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and email address 5. Quit the program Enter your choice: 2 Enter name: John Enter email address: John@yahoo.com That name already exists Menu ---------------------------------------- 1. Look up an email address 2. Add a new name and email address 3. Change an existing email address 4. Delete a name and…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

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