20F_CST8333 Assignment 02 .docx - Assignment 02 CST8333...

This preview shows page 1 - 3 out of 12 pages.

Assignment 02 CST8333 Programming Language Research Project By Samuel Ebba 2020-10-16
1. Evidence of Learning Variable: # Declaring an list to store data records records = [] records.clear() records.extend(covid_persistence.reload_data()) Loop structure: for index in range ( len (records)): print ( str (index) + ' ' + str (records[index])) Decision structure: # A method to perform menu options def perform_options (option): if option == 1 : reload_data() elif option == 2 : persist_data() elif option == 3 : search_by_date() elif option == 4 : create_new_record() elif option == 5 : edit_record() elif option == 6 : delete_record() else : print ( 'invalid option' ) File-IO: Open file, read records, and exception handling # open file in read mode with open ( 'InternationalCovid19Cases.csv' , 'r' ) as read_obj: try : # pass the file object to reader() to get the reader object csv_reader = reader(read_obj) # Iterate over each row in the csv using reader object for row in s csv_reader: # initializing objects item = CovidRecord(row[ 0 ], row[ 1 ], row[ 2 ], row[ 3 ], row[ 4 ], row[ 5 ]) records.append(item) except : print ( "Something goes wrong!" )

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture