def random_student(student_ID): xs1 = np.arange(4) ps1 = (.32,.36,.05,.26) program_random = stats.rv_discrete(name='progs', values=(xs,ps)) program = random.randint(0,3) business_ability = random.randint(0,4) coding_ability = random.randint(0,4) work_experience = random.randint(0,4) return classes.Student("noname noname", student_ID, program, business_ability,coding_ability,work_experience,[], rankings_can_be_empty = True)
def init_students(): """ initializes all students """ for i in range(0, number_of_students): new_student = classes.Student(i, with_study_association, with_student_association) new_student.draw_study_characteristics() new_student.draw_nonstudy_characteristics() list_of_all_students.append(new_student) if i % 200 == 0: print(str(i) + " students initialized")
def create_students(): print("Creating students...") # get data for students s_f_name_col = s_sheet.col_values(3) s_l_name_col = s_sheet.col_values(2) s_focus1_col = s_sheet.col_values(4) s_focus2_col = s_sheet.col_values(5) s_adviser_col = s_sheet.col_values(6) # starts at index 2 to prevent errors from 0 and to not get the header, # does not have add at end because it needs to start at 1, and end at 9, # one less than the len of the column, gets range of teachers for index in range(1, len(s_sheet.col_values(2))): s_name = s_f_name_col[index] + " " + s_l_name_col[index] # print("Name: " + s_name) s_focus1 = s_focus1_col[index] # print("Focus 1: " + s_focus1) s_focus2 = s_focus2_col[index] # print("Focus 2: " + s_focus2) s_adviser = s_adviser_col[index] # print("Adviser: " + s_adviser) students_list.append( classes.Student(s_name, s_focus1, s_focus2, s_adviser))
# Create another grade instance, let's call it g2 print("Create a Grade instance: p02, 80, 0.50") p2 = classes.Grade("p02",80,0.50) print("Print the Grade instance") print(p2) # Maybe create more grades print("Create a Grade instance: p03, 90, 0.25") p3 = classes.Grade("p03",85,0.25) print("Print the Grade instance") print(p3) print(" ") # Create a Student instance, let's call it s1 s1 = classes.Student(1, "Jack", "Booker", [p1, p2]) # Then print s1, include descriptive print statements such as above print("Create a Student instance: 1 Booker, Jack [p01, p02])") print("Print the Student instance") print(s1) print(" ") # Demonstrate add_grade and calculate_grade print("Demonstrate appending an assignment onto the grade list") s1.add_grade(p3) print(s1) print("Demonstrate a calculation of the student's final grade") s1_final = s1.calculate_grade() print(s1_final) print(" ")
import classes participation = classes.Grade('Participation', 95, .2) quiz01 = classes.Grade('quiz01', 95, .1) quiz02 = classes.Grade('quiz02', 95, .1) quiz03 = classes.Grade('quiz03', 100, .1) essay01 = classes.Grade('essay01', 87.5, .1) essay02 = classes.Grade('essay02', 81.25, .1) essay03 = classes.Grade('essay03', 100, .1) Camille = classes.Student(1,"Camille","Emig",[participation, quiz03,quiz02,quiz01, essay03,essay02,essay01]) print(Camille)
import classes name = input("Enter your name: ") lastName = input("Enter your last name: ") programming = int(input("Enter your programming grade: ")) algebra = int(input("Enter your algebra grade: ")) calculus = int(input("Enter your calculs grade: ")) physics = int(input("Enter your physics grade: ")) writing = int(input("Enter your writing grade: ")) student1 = classes.Student(name, lastName, programming, algebra, calculus, physics, writing) student1.printInfo()
classoffering.setSessions(session) assignment[var] = classoffering return None class MyEncoder(JSONEncoder): def default(self, o): return o.__dict__ if __name__ == "__main__": course = sys.argv[1] csvpath = sys.argv[2] # course = "bs cmsc" # csvpath = "../csv/4thYrKomsai3.csv" student = classes.Student(3, "2016-2017", 2, course, classes.createSubjectList(csvpath)) coursesToTake = [ classes.Subject("4", "1", "cmsc137", "core", "3", "lec"), classes.Subject("4", "1", "cmsc137", "core", "", "lab"), classes.Subject("4", "1", "cmsc142", "core", "3", "lec"), classes.Subject("4", "1", "cmsc198.1", "core", "2", "lec"), classes.Subject("4", "1", "cmsc192", "core", "1", "lec"), classes.Subject("4", "1", "", "elective", "3", "lec"), classes.Subject("4", "1", "", "elective", "3", "lec"), classes.Subject("1", "1", "", "ge(ah)", "3", "lec") ] assignment = initbacktracking(coursesToTake, student.coursesTaken, student.electiveList) try: for key in assignment.keys():
import classes new_student = classes.Student() print(new_student.name) new_student.name = 'Brian' print(new_student.name)
import classes mpl = classes.Grade('MPL', 100, .1) exam1 = classes.Grade('exam1', 72, .1) exam2 = classes.Grade('exam2', 63.33, .15) proj01 = classes.Grade('proj01', 93.33, .015) proj02 = classes.Grade('proj02', 90, .02) proj03 = classes.Grade('proj03', 65, .02) proj04 = classes.Grade('proj04', 92.5, .04) proj05 = classes.Grade('proj05', 95.56, .045) proj06 = classes.Grade('proj06', 100, .045) proj07 = classes.Grade('proj07', 100, .05) proj08 = classes.Grade('proj08', 88, .055) proj09 = classes.Grade('proj09', 50, .055) proj10 = classes.Grade('proj10', 80, .055) proj11 = classes.Grade('proj11', 90, .055) exam3 = classes.Grade('exam3', 70, .2) #rest_of_grade = classes.Grade('rest_of_grade', 87.5, .1) Elizabeth = classes.Student(1, "Elizabeth", "Schester", [ mpl, exam1, exam2, proj01, proj02, proj03, proj04, proj05, proj06, proj07, proj08, proj09, proj10, proj11, exam3 ]) print(Elizabeth)
########################################################### import classes print("Testing making a grade") new_grade = classes.Grade('test', 100, .5) #test __init__() print(new_grade, '\n') #test __str__() print("Testing making a grade with incorrect parameters") new_grade_two = classes.Grade(11, 'a', 'b') #test __init__() print(new_grade_two, '\n') #test __str__() print("Testing making a Student with correct parameters- Grace") grace_grade_one = classes.Grade('test', 100, .5) #test __init__() grace_grade_two = classes.Grade('test2', 50, .5) #test __init__() Grace = classes.Student(1, "Grace", "A", [grace_grade_one, grace_grade_two]) #test __init__() print(Grace) #test __str__() print("Testing making a Student with incorrect parameters- No Name" ) #test __init__() NoName = classes.Student('1', 2, 3, [4, 5]) print(NoName) #test __str__() print("Testing adding a grade- Julie") Julie = classes.Student(1, "Julie", "a") print(Julie) julie_grade_one = classes.Grade('test', 100, .5) #test __init__() Julie.add_grade(julie_grade_one) print(Julie) print("Testing adding a grade- Julie") julie_grade_two = classes.Grade('test2', 50, .5) #test __init__()
'This course is not currently offered. Please add new course or select from the following offerings: ' ) course_offering = reg.CourseOffering(course) institution.add_course_offering(course_offering) print('\n' + course_offering.__str__() + ' has been scheduled!' + '\n') ################################################################################################## elif menu_input == '3': #OPTION 3 - Show available courses institution.list_course_catalog() ################################################################################################## elif menu_input == '4': #OPTION 4 - Register Student to the system first_name = input('First name: ') last_name = input('Last name: ') username = input('Assign unique username: '******'\n' 'Student ' + student.first_name + ' ' + student.last_name + ' has been enrolled!' + '\n') ################################################################################################## elif menu_input == '5': #OPTION 5 - REGISTER A STUDENT FOR A COURSE while True: username = input('Student username: '******'Student username not found, please enroll student or try again'
for i in range(len(students_grades)): for j in range(len(students_grades[i])): students_grades[i][j] = classes.Grade(project_names[j],\ float(students_grades[i][j]),weights[j]) grades_dictionary[int(student_ids[i])] = students_grades[i] students_list = [] for line in students: #Gets student information from students file information = line.split() stu_id = information[0] stu_first = information[1] stu_last = information[2] #makes a student object from information in the students file and #appends it to a list students_list.append(classes.Student(int(stu_id), stu_first, stu_last,\ grades_dictionary[int(stu_id)])) #Sets variables for class average number_of_students = 0 class_average = 0 #Prints data for each student and adds each final grade to the class average for student in students_list: print(student) class_average += student.calculate_grade() number_of_students += 1 #Computes and prints class average class_average = class_average / number_of_students print("{}{:.2f}%".format("The class average is: ", class_average))
def Main(): # Try block for exception handling try: # While statments for GIGO firstName = input('Enter Students First Name: ') while firstName == '': print('Error: Cannot be blank') firstName = input('Enter Students First Name: ') lastName = input('Enter Students Last Name: ') while lastName == '': print('Error: Cannot be blank') lastName = input('Enter Students Last Name: ') addressInfo = input('Enter Students Address: ') while addressInfo == '': print('Error: Cannot be blank') addressInfo = input('Enter Students Address: ') print('Please use format \'xxx-xx-xxxx\'') phoneNumber = input('Enter Students Phone Number: ') while phoneNumber == '': print('Error: Cannot be blank') phoneNumber = input('Enter Students Phone Number: ') studentID = input('Enter Students ID Number: ') while studentID == '': print('Error: Cannot be blank') studentID = input('Enter Students ID Number: ') # While statement for ensuring credits between 1 and 16 (should 0 be included?) studentCreds = int(input('Enter Students Credits This Term: ')) while studentCreds < 1 or studentCreds > 16: print( 'Error: Student Cannot have less than 1 credit or more than 16 credits per semester!' ) studentCreds = int(input('Enter Students Credits This Term: ')) print('Enter Yes or No') inputEnroll = input('Is Student Enrolled Next Term? ') # While block to ensure user can only input certain values while inputEnroll not in ('Yes', 'No', 'yes', 'no'): print('Error: Yes and No input only') inputEnroll = input('Is Student Enrolled Next Term? ') # Evaulates and assigns boolean value based on user input if inputEnroll == 'Yes': studentEnroll = True elif inputEnroll == 'yes': studentEnroll = True elif inputEnroll == 'No': studentEnroll = False elif inputEnroll == 'no': studentEnroll = False # print header print() print('STUDENT INFORMATION') print('-------------------') # passes info to classes and getters/setters assigns values studentInfo = classes.Student(firstName, lastName, addressInfo, phoneNumber, studentID, studentCreds, studentEnroll) # calls DisplayInfo() to print information to screen classes.Student.displayInfo(firstName, lastName, addressInfo, phoneNumber, studentID, studentCreds, studentEnroll) # Catches non-integer numbers except ValueError: print('Error: Credits needs to be an Integer') # general exception except Exception as err: print('Error: ', err)
import classes class Employee: empCount = 0 def __init__(self, name, salary): self.name = name self.salary = salary Employee.empCount += 1 def display(self): print('total number of employee = ', Employee.empCount) def dispEmpl(self): print('name = ', self.name, 'salary = ', self.salary) def __del__(self): print(self.__class__.__name__, 'destroyed') emp1 = Employee("dksjfa", 1000) emp2 = Employee("hsdfjk", 2000) emp1.display() emp1.dispEmpl() emp2.dispEmpl() student1 = classes.Student("sumit", 20) student1.disp()
wildcard_courseTypes_max_counts = getWildCardCourses(allCourses) wildcard_courseTypes_current_counts = getCurrentCounts( coursesTaken, wildcard_courseTypes_max_counts) wildcard_courseTypes_lacking_counts = getLackingCounts( wildcard_courseTypes_max_counts, wildcard_courseTypes_current_counts) output = [] name_coursesTaken = [course.courseName for course in coursesTaken] for course in allCourses: if course.courseName.strip() != '': #if not blank, match name if course.courseName not in name_coursesTaken: output.append(course) else: # blank course name, match type courseType = course.courseType if wildcard_courseTypes_lacking_counts[courseType] > 0: output.append(course) wildcard_courseTypes_lacking_counts[courseType] -= 1 return output if __name__ == '__main__': student = classes.Student( 3, "2016-2017", 2, "bs cmsc", classes.createSubjectList("../csv/3rdYrKomsai.csv")) neededcourses = coursesToTake(student.allCourses, student.coursesTaken) for neededcourse in neededcourses: neededcourse.displaySubject()
def read_file(fp_students, fp_grades): """ Processes files into grade and student objects. The grade objects are added to their respective student object fp_students: the students.txt file pointer fp_grades: the grades.txt file pointer student_list: a list of the complete student objects """ student_list, grades_list, students_grades, grade_obj_list = [],[],[],[] #splits up the lines in the students.txt in order to create student objects for line in fp_students: stu_id = int(line[:1]) name1 = line[2:11].strip() name2 = line[11:].strip() student_list.append(classes.Student(stu_id, name1, name2, [])) for line in fp_grades: #determine the number of assignments that exist in the grades file num = (len(line)-13)/7 if num%7 > 7/2: #rounds up by adding 1, then rounding down num += 1 num = int(num) if grades_list == []: #initializes the grades_list to have a length equal to the number #of assignments for i in range(num): grades_list.append([]) #splits up the lines in grades.txt in order to create lists of data #that can be turned into grade objects for i in range(num): grades_list[i].append(line[13+(7*i):13+(7*(i+1))].strip()) #initializes the grade_obj_list to have as many sub-lists as students for i in range(len(student_list)): grade_obj_list.append([]) for i in range(len(grades_list)): students_grades = grades_list[i][2:] #understanding the number of assignments in gradelist, lists of grade #objects can be made for spot, individual_grade in enumerate(students_grades): grade_obj = classes.Grade(grades_list[i][1],int(individual_grade),\ float(grades_list[i][0])) grade_obj_list[spot].append(grade_obj) #because the students in students list line up with the grade lists in #grade_obj_list, the grade lists at a spot i can be added to the student #object at spot i via the Student.add_grade() function for i in range(len(student_list)): individual_grade_list = grade_obj_list[i] student_obj = student_list[i] for grade in individual_grade_list: student_obj.add_grade(grade) final_grade = 0 for student in student_list: final_grade = int(student.calculate_grade()) final_grade_str = "Final grade:{:>5}%{}".format(final_grade, " "*7) student.add_grade(final_grade_str) return student_list