def create_current_routes(): SCHOOL_ADDRESS_DICT = { "ALT": "115 A St.", # NEEDS VERIFICATION "BAR": "100 Dudley Rd.", "BRO": "575 Pleasant St.", "CAM": "215 Elm St.", "CHA": "139 Newbury St", # NEEDS VERIFICATION "DUN": "48 Frost St.", "FHS": "115 A St.", "FUL": "31 Flagg Dr.", "HEM": "729 Water St.", "JUN": "29 Upper Joclyn Ave.", "KNG": "454 Water St.", "MAR": "115 A St.", # NEEDS VERIFICATION "MCC": "8 Flagg Dr.", "POT": "492 Potter Rd.", "STA": "25 Elm St.", "STB": "115 A St.", # NEEDS VERIFICATION "WAL": "301 Brook St.", "WIL": "169 Leland St.", } school_dict = dict() bus_dict = dict() student_dict = dict() workbook = xlrd.open_workbook('2017-2018 Framingham Bus Data.xlsx') sheet = workbook.sheet_by_name('qmf_temp') for row in range(1, sheet.nrows): school_id = sheet.row(row)[0].value if school_id not in school_dict: school_address = SCHOOL_ADDRESS_DICT[school_id] + ", Framingham, MA" school_geocode = gmaps.geocode( school_address)[0]['geometry']['location'] school_dict[school_id] = School(school_id, school_geocode['lng'], school_geocode['lat']) student_id = row - 1 if student_id not in student_dict: student_address = sheet.row(row)[2].value + ", Framingham, MA" student_geocode = gmaps.geocode( student_address)[0]['geometry']['location'] student_school = school_dict[school_id] stop_address = sheet.row(row)[7].value # used AM stop destination stop_geocode = gmaps.geocode( stop_address)[0]['geometry']['location'] student_dict[student_id] = Student( student_id=student_id, res_latitude=student_geocode['lat'], res_longitude=student_geocode['lng'], school=student_school, stop_latitude=stop_geocode['lat'], stop_longitude=stop_geocode['lng']) bus_id = sheet.row(row)[4].value if bus_id not in bus_dict: bus_dict[bus_id] = Bus(bus_id=bus_id) format_dictionary(student_dict, "student")
def read_file_student(name_file1): file = open(name_file1, "r") info_file = file.read() list_row = info_file.splitlines() # save list of all the rows in the file list_student = [] # list of all the students index_sl = 0 # index course for x in list_row: x = x.split() # save list of all the words in row[i] of the file name_s = "" # name of the student for i in range(1, len(x)): name_s = name_s + x[i] list_student.append(Student(name_s.capitalize())) index_sl = index_sl + 1 file.close() return list_student
# Modules import modules as md import numpy as np import pandas as pd import matplotlib as plt r = np.random print (r) ############################################# # Classes and Objects from Classes import Student student_1 = Student("Jim", "math", 18, 3.1, True) student_2 = Student("Sam", "econ", 19, 2.5, False) #print (student_2.gpa) student_list = [1,2] student_list[0] = student_1.age student_list[1] = student_2.age print(student_list) ############################################# # A multiple choice quiz Question_Prompts = [ "How many states are in the U.S.?\n(a) 55\n(b) 45 \n(c) 50\n", "What is the color of the sky in a sunny day?\n(a) blue\n(b) red\n(c) green\n",
from Classes import Student student1 = Student("Jim", "Business", 3.5, False) student2 = Student("Pam", "Art", 2.5, True) print(student2.gpa)
from Classes import BaseClass, ChildClass, Student #Importing BaseClass, ChildClass and Student from the Classes module #simple example showing the use of the function belonging to this class print("Using BaseClass object to call function") b = BaseClass() b.hello() print() #the child class can also use this function as it is a child of BaseClass and inherites it print( "Using ChildClass object to call function which it inherites from BaseClass" ) c = ChildClass() c.hello() #Declaring a Student object inherited from Person class, uses Person classes constructor for the first three arguments. print("Creating student object which inherites from Person") s = Student("Kieran", 26, 100, 'A', "GMIT") s.printDetails() #Student object can call function from Person class print(s.grade) #Printing out the grade value print( s.school.schoolName ) #We can access the schoolname value by calling the Student object which calls the School object that was #declared inside the Student class, then from there we can reference its schoolName value.
from Classes import Student student1 = Student("Tom", "Business", "3.1", "False") student2 = Student("Jim", "Art", "2.5", "True") print(student1.gpa)
from Classes import Student, Mobile student1 = Student("Tomas", "Programming", 3.6, False) student2 = Student("Michal", "Art", 2.2, True) redmi = Mobile("Redmi 7A", "MI11", 1.25, "11.0.4", "Blue") print(student1.major) print(student2.major) print(f"{student1.name} has honor: {student1.onHonorRoll()}") print(f"{student2.name} has honor: {student2.onHonorRoll()}") print( f"Mobile name: {redmi.name}, Version: {redmi.OS} {redmi.version}, Colour: {redmi.colour}" ) name = input("Zadejte jmeno mobilu: ") OS = input("Zadejte operacni system: ") weight = input("Zadejte vahu: ") version = input("Zadejte verzi mobilu: ") colour = input("Zadejte barvu mobilu: ") newPhone = Mobile(name, OS, weight, version, colour) print( f"Mobile name: {newPhone.name}, Version: {newPhone.OS} {newPhone.version}, Colour: {newPhone.colour}, Weight: {newPhone.weight}" )
from Classes import BaseClass, ChildClass, Student #Importing BaseClass, ChildClass and Student from the Classes module #simple example showing the use of the function belonging to this class print("Using BaseClass object to call function") b = BaseClass() b.hello() print() #the child class can also use this function as it is a child of BaseClass and inherites it print("Using ChildClass object to call function which it inherites from BaseClass") c = ChildClass() c.hello() #Declaring a Student object inherited from Person class, uses Person classes constructor for the first three arguments. print("Creating student object which inherites from Person") s = Student("Kieran", 26, 100, 'A', "GMIT") s.printDetails() #Student object can call function from Person class print(s.grade) #Printing out the grade value print(s.school.schoolName) #We can access the schoolname value by calling the Student object which calls the School object that was #declared inside the Student class, then from there we can reference its schoolName value.
def get_student_list(main_sheet): student_list = [] for data_dict in main_sheet.get_all_records(): student_list.append(Student.Student(data_dict)) return student_list
class generators: """class to generate random values for driver code""" def id_generator(): result = "" for _ in range(0,4): result += str(random.randint(0, 99)) return result def name_generator(): names = ["Aaran", "Aaren", "Aarez", "Aarman", "Aaron", "Aaron-James", "Aarron", "Aaryan", "Aaryn", "Aayan", "Aazaan", "Abaan", "Abbas", "Abdallah", "Abdalroof", "Abdihakim", "Abdirahman", "Abdisalam", "Abdul", "Afonso", "Ahmad", "Ahmed", "Ahmed-Aziz", "Ahoua", "Ahtasham", "Aiadan", "Aidan", "Aiden", "Aiden-Jack", "Aiden-Vee", "Brydon-Craig", "Bryn", "Brynmor", "Bryson", "Buddy", "Bully", "Burak", "Burhan", "Butali", "Butchi", "Byron", "Cabhan", "Cadan", "Cade", "Caden", "Cadon", "Cadyn", "Caedan", "Caedyn", "Cael", "Caelan", "Caelen", "Caethan", "Cahl", "Cahlum", "Cai", "Caidan", "Caiden", "Caiden-Paul", "Caidyn", "Caie", "Cailaen", "Cailean", "Caileb-John", "Cailin", "Cain", "Caine", "Cairn", "Cal"] return f'{names[random.randint(0, 30)]} {names[random.randint(0, 30)]}' def grade_generator(): level = ["1st year", "2nd Year", "3rd Year", "4th year"] return level[random.randint(0, 3)] human1 = Person(generators.name_generator(), random.randint(18, 99), '1114 S Juanita Ave, Redondo Beach, CA, 90277') human2 = Student(generators.name_generator(), random.randint(18, 99), '5412 Pebble Ln, Loves Park, IL, 61111', generators.id_generator(),generators.grade_generator()) human3 = Employee(generators.name_generator(), random.randint(18, 99), '5412 Pebble Ln, Loves Park, IL, 61111', random.randint(30000, 1000000),random.randint(0, 40)) human4 = Faculty(generators.name_generator(), random.randint(18, 99), '5412 Pebble Ln, Loves Park, IL, 61111', random.randint(30000, 1000000),random.randint(0, 40), generators.id_generator(), "Math" ) if __name__ == "__main__": print("\n Person class: \n{}\n\n Student class: \n{}\n\n Employee class: \n{}\n\n Faculty class: \n{}\n\n ".format(human1, human2, human3, human4))
from Classes import Person if __name__ == "__main__": testPerson = Person() testPerson.getGoal() testPerson.introduce() from Classes import Student if __name__ == "__main__": testStudent = Student() testStudent.getGoal() testStudent.introduce() testStudent.skipDays(4) testStudent.introduce()