def main(argv): test1 = [[0,2,1,3,4,5], (lambda x: x % 2 == 0)] test2 = [[0,2,1,3,4,5], (lambda x: x % 2 == 1)] isCorrect = True # student = problemSet.Correct() test1_correct = str(correct_filter_array(test1[0], test1[1])) test1_student = str(student.filter_array(test1[0], test1[1])) print "Correct Output: " + test1_correct print "Your Output: " + test1_student if compare(test1_correct, test1_student): print "Correct!" else: print "Incorrect" isCorrect = False test2_correct = str(correct_filter_array(test2[0], test2[1])) test2_student = str(student.filter_array(test2[0], test2[1])) print "Correct Output: " + test2_correct print "Your Output: " + test2_student if compare(test2_correct, test2_student): print "Correct!" else: print "Incorrect" isCorrect = False
def registerStudent(self,idNo, pw, LN, FN, minUnits, maxUnits): if(idNo > 99999999 or idNo < 10000000): print("ID number should have 8 digits.") elif (minUnits > 0 and maxUnits > 0 and minUnits <= maxUnits): if len(self.__allStudents) == 0: s = Student(idNo,pw,LN,FN,minUnits,maxUnits) s.setAdmin(self) self.__allStudents.append(s) print("Successful Registration!") else: check = True for i in range (len(self.__allStudents)): if(self.__allStudents[i].getID() == idNo): check = False if(check): self.__allStudents.append(Student(idNo,pw,LN,FN,minUnits,maxUnits)) print("Successful! Student added!") return True else: print("The student is already registered.") return False else: print("Invalid inputs.") return False
def delete_student(): delete_menu = """ 1.By Name 2.By Address 3.By Contact No""" print(delete_menu) delete_choice = int(input("Enter choice")) if delete_choice == 1: delete_name = input("Enter the to name delete") d = Student(name=delete_name) is_deleted = student_database.delete_by_name(d) if is_deleted: print("The data is deleted") else: print("The data is not deleted") elif delete_choice == 2: delete_address = input("Enter the address to delete") d = Student(name=None, address=delete_address, contact_no=None) is_deleted = student_database.delete_by_address(d) if is_deleted: print("The data is deleted") else: print("The data is not deleted") elif delete_choice == 3: delete_contact = input("Enter the contact no to delete") d = Student(name=None, address=None, contact_no=delete_contact) is_deleted = student_database.delete_by_contact_no(d) if is_deleted: print("The data is deleted") else: print("The data is not deleted") else: print("Invalid choice")
def btnConfirm_1click(p1): print('LogIn_support.btnConfirm_1click') sys.stdout.flush() print(w.Entry1.get()) print(w.Entry2.get()) global data global data1 data = w.Entry1.get() data1 = w.Entry2.get() src = "LogIn," + data + "," + data1 print(src) Main_support.my_socket.sendall(src.encode('latin-1')) #w.Entry1.delete(0,len(w.Entry1.get())+1) #w.Entry2.delete(0,len(w.Entry2.get())+1) #print('wrong') data2 = Main_support.my_socket.recv(1024).decode() print(data2) if data2 == "ERROR": print("wrong") w.Entry1.delete(0, len(data) + 1) else: if data2 == 'Student': print('im in') import Student Student.create_Student(root, 'Hello', top_level) if data2 == 'Teacher': print('im in') import Teacher Teacher.create_Teacher_first(root, 'Hello', top_level)
def __init__(self, rollno=0, name=" ", marks1=0, marks2=0): Student.__init__(self, rollno, name) #OR #super().__init__(rollno,name) self.__marks1 = marks1 self.__marks2 = marks2 self.__total = self.__marks1 + self.__marks2f
def createStudent(root, nameEntry, emailEntry, passwordEntry, passwordDupEntry, studentNumEntry): """ Create a student object and insert it into a .csv file """ name = nameEntry.get() email = emailEntry.get() pwd = passwordEntry.get() pwdDup = passwordDupEntry.get() studentNum = studentNumEntry.get() resultLabel = Label(root, text="") resultLabel.grid(row=8, column=1) # check if fields are empty if (entryIsEmpty(name) or entryIsEmpty(email) or entryIsEmpty(pwd) or entryIsEmpty(pwdDup) or entryIsEmpty(studentNum)): resultLabel.config(text="One or more fields are empty.") else: if matchPasswords(pwd, pwdDup): # create student object s = Student(None, name, email, pwd, studentNum) resultLabel.config(text="Profile Successfully Created!") # insert into CSV s.insertStudent() # clear fields nameEntry.delete(0, 'end') emailEntry.delete(0, 'end') passwordEntry.delete(0, 'end') passwordDupEntry.delete(0, 'end') studentNumEntry.delete(0, 'end') # close the window root.destroy() else: resultLabel.config(text="Passwords don't match")
def main(argv): test1 = [2, 3] test2 = [25, 0] isCorrect = True # student = problemSet.Correct() test1_correct = str(correct_div_check(test1[0], test1[1])) test1_student = str(student.div_check(test1[0], test1[1])) print "Correct Output: " + test1_correct print "Your Output: " + test1_student if compare(test1_correct, test1_student): print "Correct!" else: print "Incorrect" isCorrect = False test2_correct = str(correct_div_check(test2[0], test2[1])) test2_student = str(student.div_check(test2[0], test2[1])) print "Correct Output: " + test2_correct print "Your Output: " + test2_student if compare(test2_correct, test2_student): print "Correct!" else: print "Incorrect" isCorrect = False
def main(): manager = Manager() dic = manager.dict() stud = Student("alex", 23, "male", 100) print(id(stud)) th = threading.Thread(target=testFunc_thread, args=(stud, testFunc_thread)) th.start() pro = Process(target=testFunc_process, args=(dic, stud, testFunc_process)) dic["student"] = stud pro.start() pro.join() th.join() print(stud.infoo()) print(id(stud)) print(type(dic)) print(dic) lis1 = [] print("dic id :", id(dic)) print("===================") import time for i in range(20): ida = id(dic["student"]) print(ida)
def paaa(self): stu = Student() stu.username = u print("\n\n\n\n") print("u: ", u) print("student: ", stu.username) print("\n\n\n\n")
def main(argv): test1 = [[-12, 0, 4, 10], 4] test2 = [[0, 1, 2, 3, 4], 500] isCorrect = True # student = problemSet.Correct() test1_correct = str(correct_binary_search(test1[0], test1[1])) test1_student = str(Student.binary_search(test1[0], test1[1])) print "Correct Output: " + test1_correct print "Your Output: " + test1_student if compare(test1_correct, test1_student): print "Correct!" else: print "Incorrect" isCorrect = False test2_correct = str(correct_binary_search(test2[0], test2[1])) test2_student = str(Student.binary_search(test2[0], test2[1])) print "Correct Output: " + test2_correct print "Your Output: " + test2_student if compare(test2_correct, test2_student): print "Correct!" else: print "Incorrect" isCorrect = False
def main(argv): test1 = [100, [1, 5, 10, 25]] test2 = [200, [1, 5, 10, 25]] isCorrect = True # student = problemSet.Correct() test1_correct = str(correct_changes(test1[0], test1[1])) test1_student = str(student.changes(test1[0], test1[1])) print "Correct Output: " + test1_correct print "Your Output: " + test1_student if compare(test1_correct, test1_student): print "Correct!" else: print "Incorrect" isCorrect = False test2_correct = str(correct_changes(test2[0], test2[1])) test2_student = str(student.changes(test2[0], test2[1])) print "Correct Output: " + test2_correct print "Your Output: " + test2_student if compare(test2_correct, test2_student): print "Correct!" else: print "Incorrect" isCorrect = False
def parseContentByJSONPATH(content): """ 解析content 内容 使用jsonpath :param content: json数据 :return: Studnet """ jsondata = json.loads(content) data = jsonpath.jsonpath(jsondata, "$.data.messageBOs[*]") for i in range(0, len(data)): try: studentdata = jsonpath.jsonpath(jsondata, "$.data.messageBOs[" + str(i) + "]") # id studentid = jsonpath.jsonpath(studentdata, "$..studentBO.id") # 对象赋值 student = Student() student.studentId = studentid #执行sql语句 count = insertStudentid2Studnet(student) if count >= 1: logger.info("success") else: logger.info("插入失败"+str(student)) except Exception,e: logger.info(e) logger.info("解析出现异常") continue
def get(self): requestedArgs = getArguments(['cmd', 'studentId', 'name', 'email', 'creationTime']) args = requestedArgs.parse_args() if args['cmd'] == 'getStudentsByEmail': return Student.getStudentsByEmail(self.session, args['email']) if args['cmd'] == 'getStudentsByStudentId': return Student.getStudentsByStudentId(self.session, args['studentId']) return Student.getStudents(self.session)
def BMenu(opt): if opt == '1': print() name = input("Please Enter Book Catagory : ") s.ViewByCat(cat) AMenu() elif opt == '2': ViewBorrowed() AMenu() elif opt == '3': ViewAvailable() AMenu() elif opt == '4': s.ViewAll() AMenu() elif opt == '5': s.ViewNames() AMenu() elif opt == '6': s.ViewCat() AMenu() elif opt == '7': ViewRegStudents() AMenu() elif opt == '8': print() name = input("Please Enter Book Name : ") author = input("Please Enter Author : ") catagory = input("Please Enter Catagory : ") AddBook(name, author, catagory) AMenu() elif opt == '9': print() name = input("Please Enter Your Name : ") s_name = input("Please Enter Your Surname : ") num = input("Please Enter your Student number : ") AddUser(name, s_name, num) AMenu() elif opt == '10': print() name = input("Please Enter Book Name : ") DeleteBook(name) AMenu() elif opt == '11': print() name = input("Please Enter Name of the User to delete : ") DeleteUser(name) AMenu()
def main(): name = input("What is the name?") user1 = Student(name, 0, 0) infoStr = input("Enter course info (gradepoints <space> credits): ") while infoStr != "": gp, credits = infoStr.split() user1.addLetterGrade(gp, float(credits)) infoStr = input("Enter course info (gradepoints <space> credits): ") print(user1.gpa())
def main(): student1 = Student("Sean", "B", 1) student2 = Student("Joe", "B", 2) student3 = Student("Jane", "A", 3) student1.printStudent() student2.printStudent() student3.printStudent()
def add_student_menu(): try: print("Enter student name: ") name = input() print("Enter ID number: ") id = input() if id.isnumeric() and len(id) == 8: s_list.addStudent (Student(name, id)) print(str(Student(name, id)) + " added to student list.") except: print("invalid student info") return
def get_student(id: int): err = 'error' msg = f"no student with id {id}" for s in students: tmp = Student(sid=id, name=None, language=None, framework=None, loves=None) if tmp.__eq__(s): return s.__dict__ return {err: msg}
def main(): global ProfessorList, StudentList, ManagerList select = 0 while select != 6: select = int(input("1.Professor 2.Manager 3.Student 6.exit\n")) if select == 1: Professor.main(ProfessorList, ManagerList) elif select == 2: Manager.main(ManagerList) elif select == 3: Student.main(StudentList) else: print("종료 합니다.") break
def prompt(): global courses, students result=True print("Welcome to Schedule Builder!") print("1) Student") print("2) Teacher") x = int(input("What is your position? ")) print("\n") sName = "" if(x==1): sID = input("Enter your Student ID: ") for j in range(0, len(students)): if((students[j]).getID() == int(sID)): s = students[j] sName = s.getName() if(sName == ""): print("No student with that ID was found. Follow instructions below\n") sName = input("Enter your Name: ") s = Student.Student(name=sName, ID=len(students)) print("Your ID number is: ", len(students)) students.append(s) while(result): result = studentPrompt(s) elif(x==2): tID = print("Enter your Teacher ID: ") result = teacherPrompt(tID) else: result = True print("Wrong selection\n") print("\n") return result
def getStudentData(): studentData = [] try: file = open(studentDataFile, 'r', encoding='utf-8') except IOError: return None file.readline() while True: data = file.readline().split(',') if len(data) != 1: classId = int(data[0]) familyId = int(data[1]) studentId = int(data[2]) lastName = data[3] middleName = data[4] firstName = data[5][:len(data[5]) - 1] totalScore = 1 #int(data[6]) percent = 1 #int(data[7]) grade = 1 #data[8][:-1] s_data = Student.Student(classId, studentId, familyId, lastName, middleName, firstName, totalScore, percent, grade) studentData.append(s_data) else: break file.close() return studentData
def studentSystem(): with open('Data/users.json') as json_file: users = json.load(json_file) with open('Data/courses.json') as json_file: courses = json.load(json_file) professorSystem = Student.Student('yted91', users, courses) return professorSystem
def update_student(self, student_id, course_id, major_id, course_rating=0): """Update student information with an added course and changed major and optional rating.""" if student_id not in self.student_index: self.student_index[student_id] = Student.Student(student_id) self.student_index[student_id].add_course(course_id, course_rating) self.student_index[student_id].update_major(major_id)
def showModel(num): print("--------------1.login--------------") print("--------------2.register--------------") print("--------------3.exit---------------") choose = input("choose>>:").strip() if num == 2: # 老师 if choose == "1": teacher_id = int(input("input your teacher id>>:").strip()) teacher = Teacher.Teacher(teacher_id) teacherMenu(teacher) elif choose == "2": createTeacher() main() elif choose == "3": exit(0) else: print("\033[31mInput Error!\033[0m") elif num == 1: # 学生 if choose == "1": stu_id = input("input your student id>>:").strip() student = Student.Student(stu_id) studentMenu(student) elif choose == "2": createStudent() main() elif choose == "3": exit(0) else: print("\033[31mInput Error!\033[0m") else: main()
def getStudentInfo(self, sID): database = self.getDatabaseConnection() cursor = database.cursor() sID = int(sID) try: cursor.execute("SELECT * FROM Student") students = cursor.fetchall() except sqlite3.Error as error: print("Failed to retrieve student info from database", error) finally: database.close() for s in students: if int(s[0]) == sID: theStudent = Student.Student(sID, fname=s[1], lname=s[2], addr=s[3], pnum=s[4]) try: return theStudent except: print( "Error: Student not found exception. Check inside getStudentInfo()" )
def readData(): students = open('Student.txt', 'r') courses = open('Course.txt', 'r') grades = open('Grades.txt', 'r') for line in students: temp = line.split(', ', 2) temp[2] = temp[2].replace("\n", "") tempStudent = Student.Student(int(temp[0]), temp[1], temp[2]) studentList.append(tempStudent) for line in courses: temp = line.split(', ', 2) temp[2] = temp[2].replace("\n", "") tempCourse = Course.Course(int(temp[0]), temp[1], temp[2]) courseList.append(tempCourse) for line in grades: temp = line.split(', ', 5) temp[5] = temp[5].replace("\n", "") tempGrade = Grades.Grades(int(temp[0]), int(temp[1]), float(temp[2]), float(temp[3]), float(temp[4]), float(temp[5])) gradeList.append(tempGrade) students.close() courses.close() grades.close() return
def add_student(self, conn, student_name, student_id, student_email): # Generate a random id for the student id = str(uuid.uuid4()) c = conn.cursor() try: # Create the user and tell them what we have done c.execute( 'INSERT INTO students VALUES ("{f}", "{s}", "{t}", "{r}")'. format(f=id, s=student_id, t=student_name, r=student_email)) conn.commit() self.student_temp = Student("", student_id, student_name, student_email, id) choice = QtWidgets.QMessageBox.question( self.CNStudent, 'Congrats!', 'You successfully created the student "{0}"' ' with the student ID "{1}"'.format(student_name, id), QtWidgets.QMessageBox.Ok) if choice: pass except sqlite3.IntegrityError: pass
def save_student(): if not request.json or not 'email' in request.json: abort(400) json_response = Student.save_student(conn, request.json) return jsonify(json_response)
def _loadFile(self): f = open(self._filename, 'r') f1 = f.readlines() for line in f1: line = line.split(';') student = Student(int(line[0]), line[1]) self.addStudent(student)
def addMember(studentID, name, request, sessionID): student = Student(studentID, name, request) #print(student.verify) studentArray.append(student) sessionDict[sessionID].addStudent(student) return
def InsertAllStudents(A, filename): StudentFile = open(filename, "r") for line in StudentFile: line = line.split() student = Student.Student(line[0], line[1], line[2], line[3], line[4]) A.Insert(student) StudentFile.close()
def student_system(): gradingSystem = System.System() gradingSystem.load_data() name = 'yted91' studentSystem = Student.Student(name, gradingSystem.users, gradingSystem.courses) return studentSystem
def get_students(columns): students, error = Student.get_students(conn, columns) d = {} d["students"] = students d["error"] = error return jsonify(d)
def test_readUserFile(self): '''If everything's coded right, this should never encounter an empty Users.csv, nor Users with missing values, so testing for any number of Users should be the same and so there's only 1 test.''' # Generating Testing-only version of Users.csv. # Not using CSV Writer, as it doesn't write lines, just writes everything on one line. csv_file = open("TestUsers.csv", "w") csv_file.write("0,s,s,s,s,S\n") csv_file.write("1,p,p,p,p,P\n") csv_file.close() Users = [ Student.Student('0', "s", "s", "s", "s"), Professor.Professor('1', "p", "p", "p", "p") ] U = SignIn.readUserFile("TestUsers.csv") s = set() # Just check against the known values. for i in range(len(U)): s.add(U[i].getName() == Users[i].getName()) s.add(U[i].getEmail() == Users[i].getEmail()) s.add(U[i].getPassword() == Users[i].getPassword()) s.add(U[i].getPersonnelNumber() == Users[i].getPersonnelNumber()) s.add(U[i].getType() == Users[i].getType()) s.add(U[i].getId() == Users[i].getId()) self.assertTrue(len(s) == 1)
def check_student_info(): if not request.json or not 'email' in request.json or not 'password' in request.json: abort(400) json_response = Student.check_students(conn, request.json) return jsonify(json_response)
def createStudent(): print("New Student!") name = input("Enter name: ") age = int(input("Enter age: ")) gpa = float(input("Enter gpa: ")) gradeLevel = input("Enter Grade Level: ") return Student.Student(name, age, gpa, gradeLevel)
def main(argv): test1 = [[0,1,2,3], 0] test2 = [[-10,-3,0,45], -3] test3 = [[-12, 10, 23, 30], 30] isCorrect = True # student = problemSet.Correct() test1_correct = str(correct_binary_search(test1[0], test1[1])) test1_student = str(student.binary_search(test1[0], test1[1])) print "Correct Output: " + test1_correct print "Your Output: " + test1_student if compare(test1_correct, test1_student): print "Correct!" else: print "Incorrect" isCorrect = False test2_correct = str(correct_binary_search(test2[0], test2[1])) test2_student = str(student.binary_search(test2[0], test2[1])) print "Correct Output: " + test2_correct print "Your Output: " + test2_student if compare(test2_correct, test2_student): print "Correct!" else: print "Incorrect" isCorrect = False test3_correct = str(correct_binary_search(test3[0], test3[1])) test3_student = str(student.binary_search(test3[0], test3[1])) print "Correct Output: " + test3_correct print "Your Output: " + test3_student if compare(test3_correct, test3_student): print "Correct!" else: print "Incorrect" isCorrect = False
def main(argv): test1 = [1] test2 = [3] test3 = [5] isCorrect = True # student = problemSet.Correct() test1_correct = str(correct_pascal(test1[0])) test1_student = str(student.pascal(test1[0])) print "Correct Output: " + test1_correct print "Your Output: " + test1_student if compare(test1_correct, test1_student): print "Correct!" else: print "Incorrect" isCorrect = False test2_correct = str(correct_pascal(test2[0])) test2_student = str(student.pascal(test2[0])) print "Correct Output: " + test2_correct print "Your Output: " + test2_student if compare(test2_correct, test2_student): print "Correct!" else: print "Incorrect" isCorrect = False test3_correct = str(correct_pascal(test3[0])) test3_student = str(student.pascal(test3[0])) print "Correct Output: " + test3_correct print "Your Output: " + test3_student if compare(test3_correct, test3_student): print "Correct!" else: print "Incorrect" isCorrect = False
def main(argv): test1 = ["Test", "Not anagram"] test2 = ["CAT", "TAC"] test3 = ["ANAGRAM", "MARANAG"] isCorrect = True #student = problemSet.Correct() test1_correct = str(correct_is_anagram(test1[0], test1[1])) test1_student = str(student.is_anagram(test1[0], test1[1])) print "Correct Output: " + test1_correct print "Your Output: " + test1_student if compare(test1_correct, test1_student): print "Correct!" else: print "Incorrect" isCorrect = False test2_correct = str(correct_is_anagram(test2[0], test2[1])) test2_student = str(student.is_anagram(test2[0], test2[1])) print "Correct Output: " + test2_correct print "Your Output: " + test2_student if compare(test2_correct, test2_student): print "Correct!" else: print "Incorrect" isCorrect = False test3_correct = str(correct_is_anagram(test3[0], test3[1])) test3_student = str(student.is_anagram(test3[0], test3[1])) print "Correct Output: " + test3_correct print "Your Output: " + test3_student if compare(test3_correct, test3_student): print "Correct!" else: print "Incorrect" isCorrect = False
def main(argv): test1 = [newtoncooling, 100,0,100,10] isCorrect = True # student = problemSet.Correct() test1_correct = str(correct_euler(test1[0], test1[1], test1[2], test1[3], test1[4])) test1_student = str(student.euler(test1[0], test1[1], test1[2], test1[3], test1[4])) print "Correct Output: " + test1_correct print "Your Output: " + test1_student if compare(test1_correct, test1_student): print "Correct!" else: print "Incorrect" isCorrect = False
def main(argv): test1 = [1] test2 = [10] test3 = [101] isCorrect = True test1_correct = str(correct_doors(test1[0])) test1_student = str(student.doors(test1[0])) print "Correct Output: " + test1_correct print "Your Output: " + test1_student if compare(test1_correct, test1_student): print "Correct!" else: print "Incorrect" isCorrect = False test2_correct = str(correct_doors(test2[0])) test2_student = str(student.doors(test2[0])) print "Correct Output: " + test2_correct print "Your Output: " + test2_student if compare(test2_correct, test2_student): print "Correct!" else: print "Incorrect" isCorrect = False test3_correct = str(correct_doors(test3[0])) test3_student = str(student.doors(test3[0])) print "Correct Output: " + test3_correct print "Your Output: " + test3_student if compare(test3_correct, test3_student): print "Correct!" else: print "Incorrect" isCorrect = False
def get_data(self,students,get_all=True, year=-1): """Returns list of students with student data information""" print 'From year:', (str(year)+'-'+str(year+1)) print 'From title:',self.s.title # Check if year is requested year if year != -1 and (str(year)+'-'+str(year+1)) != self.s.title: return for row in range(self.header_row+1,self.s.get_highest_row()+1): rowID = 0 val1 = self.s.cell(row=row,column=self.id_column).value if self.s.cell(row=row,column=self.id_column).data_type == 's': # remove hyphens val1 = val1.replace('-','') rowID = atoi(val1) else: rowID = int(val1) student = find_by_id(students,rowID) if student is None: if get_all: student = Student() students.append(student) else: continue # Get ID and year student.stuID = rowID student.set_hs_grade(int(self.s.cell(row=row,column=self.grade_column).value)) # Get Name student.last = str(self.s.cell(row=row,column=self.last_column).value) student.first = str(self.s.cell(row=row,column=self.first_column).value) # DOB if str(self.s.cell(row=row,column=self.dob_column).value) == "None": student.dob = "" else: time_tuple = time.strptime(str(self.s.cell(row=row,column=self.dob_column).value),"%Y-%m-%d %H:%M:%S") student.dob = str(time_tuple.tm_mon)+"/"+str(time_tuple.tm_mday)+"/"+str(time_tuple.tm_year)
def ReadMaster(docsFile, students,sections,target_grade = -1): gd_client = gdata.spreadsheet.service.SpreadsheetsService() email = raw_input('Enter DP username: (omit @democracyprep.org) ') email += '@democracyprep.org' gd_client.email = email passwd = getpass.getpass(prompt='Enter Password: '******'DPGoogleSheet' gd_client.source = 'MasterSchedule' gd_client.ProgrammaticLogin() q = gdata.spreadsheet.service.DocumentQuery() q['title'] = docsFile q['title-exact'] = 'true' feed = gd_client.GetSpreadsheetsFeed(query=q) spreadsheet_id = feed.entry[0].id.text.rsplit('/',1)[1] feed = gd_client.GetWorksheetsFeed(spreadsheet_id) worksheet_id = feed.entry[0].id.text.rsplit('/',1)[1] for worksheet in feed.entry: if 'MonThurSections' in str(worksheet.title): worksheet_id = worksheet.id.text.rsplit('/',1)[1] rows = gd_client.GetListFeed(spreadsheet_id, worksheet_id).entry for row in rows: #for key in row.custom: # print " %s: %s" % (key, row.custom[key].text) title = row.custom['course'].text grades = row.custom['primarygrade'].text period = row.custom['period'].text subject = 'all' teacher = row.custom['teacher'].text if teacher == None: teacher = '-' room = row.custom['classroom'].text sections.append(Section(title=title,subject=subject,teacher=teacher,period=int(period),room=room)) for worksheet in feed.entry: if 'FridaySection' in str(worksheet.title): worksheet_id = worksheet.id.text.rsplit('/',1)[1] rows = gd_client.GetListFeed(spreadsheet_id, worksheet_id).entry for row in rows: title = row.custom['course'].text grades = row.custom['primarygrade'].text period = row.custom['period'].text subject = 'all' teacher = row.custom['teacher'].text if teacher == None: teacher = '-' room = row.custom['classroom'].text sections.append(Section(title=title,subject=subject,teacher=teacher,period=int(period),room=room, friday=True)) for worksheet in feed.entry: if 'Students' in str(worksheet.title): worksheet_id = worksheet.id.text.rsplit('/',1)[1] rows = gd_client.GetListFeed(spreadsheet_id, worksheet_id).entry for row in rows: #for key in row.custom: # print " %s: %s" % (key, row.custom[key].text) grade = row.custom['grade'].text if 'Leave' in grade: continue #if grade != target_grade and target_grade != -1: continue ID = row.custom['studentid'].text last = row.custom['lastname'].text first = row.custom['firstname'].text advisor = row.custom['advisor'].text homeroom = row.custom['homeroom'].text student = Student(stuID=ID,last=last,first=first,homeroom=homeroom,advisor=advisor) student.set_hs_grade(grade) students.append(student) for period in xrange(1,10): sec_title = row.custom['period'+str(period)].text if sec_title == None: continue sec_found = False for section in sections: if sec_title == section.title and period == section.period and not section.is_friday: section.students.append(student) student.schedule[period-1] = section sec_found = True if not sec_found: print 'WARNING: ',sec_title, 'not found in section catalog.' tmp_section = Section(title=sec_title,subject='all',teacher='',period=int(period)) student.schedule[period-1] = tmp_section for period in xrange(1,7): sec_title = row.custom['fridayperiod'+str(period)].text sec_found = False for section in sections: if sec_title == section.title and period == section.period and section.is_friday: section.students.append(student) student.friday_schedule[period-1] = section sec_found = True if not sec_found: print 'WARNING: ',sec_title, 'not found in friday section catalog.' tmp_section = Section(title=sec_title,subject='all',teacher='',period=int(period),friday=True) student.friday_schedule[period-1] = tmp_section
def main(argv): test1 = [[0,1,10,110,111]] test2 = [[111,110,10,1,1]] test3 = [[0,0,0,0,0,0,0]] test4 = [[10, 20]] test5 = [[20, 10]] test6 = [[10]] isCorrect = True test1_correct = str(correct_radix_sort(test1[0])) test1_student = str(student.radix_sort(test1[0])) print "Correct Output: " + test1_correct print "Your Output: " + test1_student if compare(test1_correct, test1_student): print "Correct!" else: print "Incorrect" isCorrect = False test2_correct = str(correct_radix_sort(test2[0])) test2_student = str(student.radix_sort(test2[0])) print "Correct Output: " + test2_correct print "Your Output: " + test2_student if compare(test2_correct, test2_student): print "Correct!" else: print "Incorrect" isCorrect = False test3_correct = str(correct_radix_sort(test3[0])) test3_student = str(student.radix_sort(test3[0])) print "Correct Output: " + test3_correct print "Your Output: " + test3_student if compare(test3_correct, test3_student): print "Correct!" else: print "Incorrect" isCorrect = False test4_correct = str(correct_radix_sort(test4[0])) test4_student = str(student.radix_sort(test4[0])) print "Correct Output: " + test4_correct print "Your Output: " + test4_student if compare(test4_correct, test4_student): print "Correct!" else: print "Incorrect" isCorrect = False test5_correct = str(correct_radix_sort(test5[0])) test5_student = str(student.radix_sort(test5[0])) print "Correct Output: " + test5_correct print "Your Output: " + test5_student if compare(test5_correct, test5_student): print "Correct!" else: print "Incorrect" isCorrect = False test6_correct = str(correct_radix_sort(test6[0])) test6_student = str(student.radix_sort(test6[0])) print "Correct Output: " + test6_correct print "Your Output: " + test6_student if compare(test6_correct, test6_student): print "Correct!" else: print "Incorrect" isCorrect = False
def main(): config = ConfigParser.RawConfigParser() config.read("posconfig.txt") waitSecs = config.getint("general","seconds_lights_on") #sets up the socket host = config.get("database", "host") port = config.getint("database", "port") responseSize = config.getint("database","responseSize") greenLight = light(config.getint("light", "greenPin")) redLight = light(config.getint("light", "redPin")) (rfidKeyboard, magneticKeyboard) = getKeyboards() greenLight.off() redLight.off() #print("Connecting to ", host) #posSocket.connect((host, port)) while rfidKeyboard and magneticKeyboard: idInput = readKeyboards(rfidKeyboard, magneticKeyboard) currentStudent = Student(0, 0, False, 'students.db') #process to allow id input in any order and validates the student does not have a G2G container greenLight.off() redLight.off() #student number first workflow if(currentStudent.isInputStudentId(idInput)): #sets studentNumber to scanned card currentStudent.setStudentNumber(idInput) print("Connecting to ", host) posSocket = socket.socket() posSocket.connect((host, port)) currentStudent.setHasG2G(reportId(idInput,posSocket, host, port, responseSize)) if(currentStudent.hasG2G): #Red light redLight.on() greenLight.off() else: #scan RFID idInput = readKeyboards(rfidKeyboard, magneticKeyboard) while(not(currentStudent.isInputRFID(idInput))): redLight.on() greenLight.on() idInput = readKeyboards(rfidKeyboard, magneticKeyboard) redLight.off() greenLight.on() reportRfid(idInput, posSocket, host, port) #RFID first workflow elif(currentStudent.isInputRFID(idInput)): currentStudent.setRFIDCode(idInput) idInput=readKeyboards(rfidKeyboard, magneticKeyboard) while(not(currentStudent.isInputStudentId(idInput))): redLight.on() greenLight.on() idInput = readKeyboards(rfidKeyboard, magneticKeyboard) print("Connecting to ", host) posSocket = socket.socket() posSocket.connect((host, port)) currentStudent.setStudentNumber(idInput) currentStudent.setHasG2G(reportId(idInput, posSocket, host, port, responseSize)) if(currentStudent.hasG2G): greenLight.off() redLight.on() else: redLight.off() greenLight.on() reportRfid(currentStudent.RFIDCode,posSocket, host, port) else: redLight.on() greenLight.on() print("closing connection with", host) posSocket.close()
import Student stu = Student() print stu.getName()
def main(): student1 = Student('alpha', 2018) student1.takeCourse('cis110') ta110 = TA('beta', 'cis110') ta110.pickOfficeHours('Monday', 3) ta110.pickRecitationTime(11) student1.assignRecitationTA(ta110) ta110.gradeStudent(student1, 'A') student1.printReport() student1.takeCourse('cis120') ta120 = TA('gamma', 'cis120') ta120.pickOfficeHours('Tuesday', 1) ta120.pickRecitationTime(3) student1.assignRecitationTA(ta120) ta120.gradeStudent(student1, 'B+') student1.printReport()
def main(argv): test1 = [[0,1,10,110,111], 4, 3] test2 = [[111,110,10,1,1], 5, 3] test3 = [[0,0,0,0,0,0,0], 7, 1] test4 = [[10, 20], 2, 2] test5 = [[20, 10], 2, 2] test6 = [[10], 1, 2] test7 = [[110, 10, 1001, 1, 0, 23, 43, 40], 8, 4] isCorrect = True test1_correct = str(correct_radix_sort(test1[0], test1[1], test1[2])) test1_student = str(student.radix_sort(test1[0], test1[1], test1[2])) print "Correct Output: " + test1_correct print "Your Output: " + test1_student if compare(test1_correct, test1_student): print "Correct!" else: print "Incorrect" isCorrect = False test2_correct = str(correct_radix_sort(test2[0], test2[1], test2[2])) test2_student = str(student.radix_sort(test2[0], test2[1], test2[2])) print "Correct Output: " + test2_correct print "Your Output: " + test2_student if compare(test2_correct, test2_student): print "Correct!" else: print "Incorrect" isCorrect = False test3_correct = str(correct_radix_sort(test3[0], test3[1], test3[2])) test3_student = str(student.radix_sort(test3[0], test3[1], test3[2])) print "Correct Output: " + test3_correct print "Your Output: " + test3_student if compare(test3_correct, test3_student): print "Correct!" else: print "Incorrect" isCorrect = False test4_correct = str(correct_radix_sort(test4[0], test4[1], test4[2])) test4_student = str(student.radix_sort(test4[0], test4[1], test4[2])) print "Correct Output: " + test4_correct print "Your Output: " + test4_student if compare(test4_correct, test4_student): print "Correct!" else: print "Incorrect" isCorrect = False test5_correct = str(correct_radix_sort(test5[0], test5[1], test5[2])) test5_student = str(student.radix_sort(test5[0], test5[1], test5[2])) print "Correct Output: " + test5_correct print "Your Output: " + test5_student if compare(test5_correct, test5_student): print "Correct!" else: print "Incorrect" isCorrect = False test6_correct = str(correct_radix_sort(test6[0], test6[1], test6[2])) test6_student = str(student.radix_sort(test6[0], test6[1], test6[2])) print "Correct Output: " + test6_correct print "Your Output: " + test6_student if compare(test6_correct, test6_student): print "Correct!" else: print "Incorrect" isCorrect = False test7_correct = str(correct_radix_sort(test7[0], test7[1], test7[2])) test7_student = str(student.radix_sort(test7[0], test7[1], test7[2])) print "Correct Output: " + test7_correct print "Your Output: " + test7_student if compare(test7_correct, test7_student): print "Correct!" else: print "Incorrect" isCorrect = False
def func(): stu = Student('Leo','男',24) stu.isAdult()