Question: can someone please write me a pseudocode for the code below please? import csv import sys csv_file_location = './assessments.csv' csv.register_dialect('AssDialect', delimiter='t') def read_assessments(): with open(csv_file_location)
can someone please write me a pseudocode for the code below please? import csv import sys csv_file_location = './assessments.csv' csv.register_dialect('AssDialect', delimiter='\t') def read_assessments(): with open(csv_file_location) as csvfile: return list(csv.reader(csvfile, dialect = 'AssDialect')) def list_assessments(): assessment_list = read_assessments() for row in assessment_list: print("%-14s %-18s %-20s %-10s %-12s %-10s %-10s" % tuple(row)) def add_assessment(): assessment_list = read_assessments() assessmentIds = [row[0] for row in assessment_list[1:]] while True: assessmentID = input("Assessment ID: ") if assessmentID in assessmentIds: print("Asseessment already exists.") else: break submissionDate = input("Submission Date: ") moduleName = input("Module Name: ") staffId = input("Staff ID: ") moduleCode = input("Module Code: ") weighting = input("Weighting: ") component = input("Component: ") # append the new assessment row assessment_list.append([assessmentID, submissionDate, moduleName, staffId, moduleCode, weighting, component]) # write the list of assessments with open(csv_file_location, 'w') as csvfile: writer = csv.writer(csvfile, dialect = 'AssDialect') writer.writerows(assessment_list) def update_assessment(): assessment_list = read_assessments() assessmentIds = [row[0] for row in assessment_list[1:]] while True: assessmentID = input("Enter Assessment ID to update: ") if assessmentID not in assessmentIds: print("Asseessment does not exist.") else: break submissionDate = input("Submission Date: ") moduleName = input("Module Name: ") staffId = input("Staff ID: ") moduleCode = input("Module Code: ") weighting = input("Weighting: ") component = input("Component: ") # updated assessment row newRow = [assessmentID, submissionDate, moduleName, staffId, moduleCode, weighting, component] # Traverse the list from 1 to length, once ther is mtch update the row for i in range(1,len(assessment_list)): if assessment_list[i][0] == assessmentID: assessment_list[i] = newRow break # write the list of assessments with open(csv_file_location, 'w') as csvfile: writer = csv.writer(csvfile, dialect = 'AssDialect') writer.writerows(assessment_list) def remove_assessment(assessmentID): assessment_list = read_assessments() assessmentIds = [row[0] for row in assessment_list[1:]] if assessmentID not in assessmentIds: print("Asseessment does not exist.") return # filter the list of assessment not having given assessment id assessment_list = [row for row in assessment_list if assessmentID not in row] # write the list of assessments with open(csv_file_location, 'w') as csvfile: writer = csv.writer(csvfile, dialect = 'AssDialect') writer.writerows(assessment_list) def search_assessments(level): assessment_list = read_assessments() for row in assessment_list: # Assuming Module Code contains level number # Module code is at index 4 if level in row[4]: print("%-14s %-18s %-20s %-10s %-12s %-10s %-10s" % tuple(row)) def count_assessments(): return len(read_assessments())-1 def show_menu(): choice = input(""" a.List assessments b.Enter a new assessment c.Remove an existing assessment d.Update the details of an existing assessment e.Search and display the details for a particular level f.Count the number of assessments g.Exit the program Please enter your choice: """) if choice == "a": list_assessments() elif choice == "b": add_assessment() elif choice == "c": assessmentID = input("Enter Assessment ID: ") remove_assessment(assessmentID) elif choice == "d": update_assessment() elif choice == "e": level = input("Enter Teaching Level (number): ") search_assessments(level) elif choice == "f": print("The number of assessments:", count_assessments()) elif choice=="g": sys.exit() else: print("Invalid Choice. Please try again.") show_menu() def main(): show_menu() if __name__ == "__main__": Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
