need you to add this feature to the code down below, please   def add(): id = input("Enter ID:") f = open("data.txt", "r") id_list = [] lines = f.readlines() if lines != "": for line in lines: token = line.split(" ") id_list.append(token[0]) for i in id_list: if i == id: print("The stude

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

hi I need you to add this feature to the code down below, please

 

def add():
id = input("Enter ID:")
f = open("data.txt", "r")
id_list = []
lines = f.readlines()
if lines != "":
for line in lines:
token = line.split(" ")
id_list.append(token[0])
for i in id_list:
if i == id:
print("The student record is already in the database!Zero records added")
return
f.close()
file = open("data.txt", "a")
name = input("Enter name: ")
course = input("Enter course: ")
absences = int(input("Enter absences: "))
exam1 = int(input("Enter exam 1 grade: "))
exam2 = int(input("Enter exam 2 grade: "))
marks = int(input("Enter Total Marks: "))
s = id+" "+name+" "+course+" "+str(absences)+" "+str(exam1)+" "+str(exam2)+" "+str(marks)+"\n"
file.write(s)
file.close()


while True:
print("1.Add a student")
print("Any other numeric to terminate")
choice = int(input())
if choice == 1:
add()
else:
break

2. Removing students from the class
A unique record in the database is identified by ID and Course. Using only ID will
return many records of the same student who have multiple courses and using only course
titles will return many students who have the same course. Therefore, to identify a single
record and remove it, we need to use both.
By selecting this option, the program should show to the user two other options
а. Вy ID
b. Вy Course
Once a user selects By ID (option a), the program asks the user to enter an ID to search
for. Then, the program returns all records that have the same ID. Suppose a user selected
this option and entered 202010000 to look for. Then, your program should show the
records numbered as follows
1.
202010000 Asem
ICS104 0
100
100
200
2.
202010000 Asem
ICS108 2
75
-1
75
The user, then, can select one of these showed records by entering the corresponding
number to be removed from the data file. So, if the user enters (1) then your program
should remove the first record from the data file permanently.
Note: Similar situation can be produced with By Course. The Course column will be the
same, the student names and information will be different!
Transcribed Image Text:2. Removing students from the class A unique record in the database is identified by ID and Course. Using only ID will return many records of the same student who have multiple courses and using only course titles will return many students who have the same course. Therefore, to identify a single record and remove it, we need to use both. By selecting this option, the program should show to the user two other options а. Вy ID b. Вy Course Once a user selects By ID (option a), the program asks the user to enter an ID to search for. Then, the program returns all records that have the same ID. Suppose a user selected this option and entered 202010000 to look for. Then, your program should show the records numbered as follows 1. 202010000 Asem ICS104 0 100 100 200 2. 202010000 Asem ICS108 2 75 -1 75 The user, then, can select one of these showed records by entering the corresponding number to be removed from the data file. So, if the user enters (1) then your program should remove the first record from the data file permanently. Note: Similar situation can be produced with By Course. The Course column will be the same, the student names and information will be different!
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Set
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