diff --git a/s24/AmFam_Ashwin/13_Strings/Lecture Code/project.py b/s24/AmFam_Ashwin/13_Strings/Lecture Code/project.py new file mode 100644 index 0000000000000000000000000000000000000000..4f849c570d4d9a05f8871f55dc337ab0f1aab36e --- /dev/null +++ b/s24/AmFam_Ashwin/13_Strings/Lecture Code/project.py @@ -0,0 +1,78 @@ +__student__ = [] + + +def __init__(): + """This function will read in the csv_file and store it in a list of dictionaries""" + reload() + +def reload(): + """Reloads the data from the CSV file""" + import csv + __student__.clear() + with open('cs220_survey_data.csv', mode='r', encoding='utf-8') as csv_file: + csv_reader = csv.DictReader(csv_file) + for row in csv_reader: + __student__.append(row) + +def count(): + """This function will return the number of records in the dataset""" + return len(__student__) + + +def get_lecture(idx): + """get_lecture(idx) returns the lecture of the student in row idx""" + return __student__[int(idx)]['Lecture'] + + +def get_section(idx): + """get_lecture(idx) returns the section of the student in row idx""" + return __student__[int(idx)]['section'] + + +def get_age(idx): + """get_age(idx) returns the age of the student in row idx""" + return __student__[int(idx)]['Age'] + + +def get_primary_major(idx): + """get_primary_major(idx) returns the primary major of the student in row idx""" + return __student__[int(idx)]['Primary major'] + + +def get_other_majors(idx): + """get_other_majors(idx) returns the secondary major of the student in row idx""" + return __student__[int(idx)]['Other majors'] + + +def get_zip_code(idx): + """get_zip_code(idx) returns the residential zip code of the student in row idx""" + return __student__[int(idx)]['Zip Code'] + + +def get_pizza_topping(idx): + """get_pizza_topping(idx) returns the preferred pizza toppings of the student in row idx""" + return __student__[int(idx)]['Pizza topping'] + +def get_cats_or_dogs(idx): + """get_cats_or_dogs(idx) returns whether student in row idx likes cats or dogs""" + return __student__[int(idx)]['Cats or dogs'] + +def get_runner(idx): + """get_runner(idx) returns whether student in row idx is a runner""" + return __student__[int(idx)]['Runner'] + +def get_sleep_habit(idx): + """get_sleep_habit(idx) returns the sleep habit of the student in row idx""" + return __student__[int(idx)]['Sleep habit'] + +def get_procrastinator(idx): + """get_procrastinator(idx) returns whether student in row idx is a procrastinator""" + return __student__[int(idx)]['Procrastinator'] + + +def get_song(idx): + """get_procrastinator(idx) returns the student in row idx favorite song""" + return __student__[int(idx)]['Song'] + + +__init__()