def login(): username_login = username_user.get() userpass_login = password_pass.get() if username_login == "" or userpass_login == "": msg.showerror("error", "Enter User Name And Password") else: con = mysql.connector.connect(host='localhost', user='******', password='', database='library') concommand = con.cursor() concommand.execute( "select user and pass from login where user=%s and pass = %s", (username_login, userpass_login)) result_login = concommand.fetchone() concommand.execute( "select username and password from register where username=%s and password = %s", (username_login, userpass_login)) result_register = concommand.fetchone() if result_login: msg.showinfo("SUCESS", "Welcome Admin") dash() else: if result_register: msg.showinfo("SUCESS", "Welcome Student") student() else: msg.showerror("Error", "Invalid Details") clear()
def test_eq(): eqstudent1 = student('john',3.5,10) eqstudent2 = student('john',3.5,10) assert eqstudent1 == eqstudent2 eqstudent1 = student('john',4.0,10) eqstudent2 = student('john',3.5,10) assert not eqstudent1 == eqstudent2 print "Equal test done!"
def main(): student1 = student("John Smith", "*****@*****.**") student2 = student("Name Surname Suffix", "*****@*****.**", False) admin1 = admin("Joe Admin", "*****@*****.**") admin2 = admin("root", "root@localhost", False) placeholder = person("", "") #desired output is commented next to each print statement print("Testing get name from student") print(student1.get_name()) #John Smith print(student2.get_name()) #Name Surname Suffix print("Testing get name from admin") print(admin1.get_name()) #Joe Admin print(admin2.get_name()) #root print("Testing get name from person") placeholder = student1 #John Smith print(placeholder.get_name()) placeholder = student2 #Name Surname Suffix print(placeholder.get_name()) placeholder = admin1 #Joe Admin print(placeholder.get_name()) placeholder = admin2 #root print(placeholder.get_name()) print("") print("Testing get email from student") print(student1.get_email()) #[email protected] print(student2.get_email()) #[email protected] print("Testing get email from admin") print(admin1.get_email()) #[email protected] print(admin2.get_email()) #root@localhost print("Testing get email from person") placeholder = student1 print(placeholder.get_email()) #[email protected] placeholder = student2 print(placeholder.get_email()) #[email protected] placeholder = admin1 print(placeholder.get_email()) #[email protected] placeholder = admin2 print(placeholder.get_email()) #root@localhost print("") print("Testing get attendance from student") print(student1.get_attendance()) #True print(student2.get_attendance()) #False print("") print("Testing get request from admin") print(admin1.get_admin_request()) #True print(admin2.get_admin_request()) #False
def read(): input_file = open('data.txt', 'r') lines = input_file.readlines() students_list = [] course_info_dictionary = {} for line in lines: registration_year = line.split()[0] # the first element is always the registration year data = ' '.join(line.split()[1:]) # Join the rest of the sentence but the first string which is the year all_matches = re.findall(r'(\d+\-\d+)\s(\d+)\s\"([\w|\W|\s]+?)\"\s(\d+\W\d+)\s(\d+)', data) tmp_course_list = [] if not all_matches: print 'Not found' print line for match in all_matches: course_year_month = match[0] course_code = match[1] course_name = match[2].decode('utf8') course_credit = match[3] final_grade = match[4] tmp_student_course = student_course(course_year_month, course_code, course_name, course_credit, final_grade) tmp_course_list.append(tmp_student_course) if course_code not in course_info_dictionary.keys(): course_info_dictionary[course_code] = [course_name, course_credit] students_list.append(student(registration_year, tmp_course_list)) return students_list, course_info_dictionary
def createobj(info): # info is the dictionary created by getinfo() s = student.student(info['name'], info['age'], info['regid']) s.setmarks('phy', int(info['phy'])) s.setmarks('chem', int(info['chem'])) s.setmarks('math', int(info['math'])) s.setmarks('bio', int(info['bio'])) return (s)
def create_student(email, status): if (status == "present"): status = True else: status = False return student("Filler", email, status)
def studentEdit(): global sno, students command = '' while (command.lower() != 'x'): print(''' 1 - Create student account 2 - Edit student info 3 - Delete student 4 - View students X - Cancel ''') command = input('Enter command: ') if (command == '1'): try: idno = int(input('Enter id of student: ')) name = input('Enter name of student: ') if (checkIfExist(idno, students) is None): newst = student.student(name, idno) students.append(newst) else: print('Student already exists') except: print('please enter an ID number') elif (command == '2'): editStudent() elif (command == '3'): deleteStudent() elif (command == '4'): viewList() else: print('invalid po')
def test_create(): name = 'student' GPA = 0.0 age = 16 amyStudent = student() assert amyStudent.name == name assert amyStudent.GPA == GPA assert amyStudent.age == age name = '1' GPA = 1 age = 2 amyStudent = student(name,GPA,age) assert amyStudent.name == name assert amyStudent.GPA == GPA assert amyStudent.age == age print 'Create test done!'
def Login(self, event): a = self.rbox.GetStringSelection() if a == "管理员": if self.pd(self.userText.GetValue(), self.passText.GetValue(), a): ui = admin(self.userText.GetValue()) ui.frame() self.loginFrame.Close() else: wx.MessageBox('用户名或密码错误', 'error', wx.OK | wx.ICON_ERROR) self.userText.SetValue("") self.passText.SetValue("") elif a == "教师": if self.pd(self.userText.GetValue(), self.passText.GetValue(), a): ui = teacher(self.userText.GetValue()) ui.frame() self.loginFrame.Close() else: wx.MessageBox('用户名或密码错误', 'error', wx.OK | wx.ICON_ERROR) self.userText.SetValue("") self.passText.SetValue("") else: if self.pd(self.userText.GetValue(), self.passText.GetValue(), a): ui = student(self.userText.GetValue()) ui.frame() self.loginFrame.Close() else: wx.MessageBox('用户名或密码错误', 'error', wx.OK | wx.ICON_ERROR) self.userText.SetValue("") self.passText.SetValue("")
def create_student(name, status): if (status == "present"): status = True else: status = False return student(name, "*****@*****.**", status)
def generate_random_student_list(num): student_list = [] for i in range(num): gender_ins = "" if random.random() >= 0.5: gender_ins = "Male" else: gender_ins = "Female" name_ins = name_gen(gender_ins) courses_ins = [] for j in range(len(course_list)): if random.getrandbits(1): copied_list = course_list.copy() copied_list[j - 1].optional_grade = available_grades[ random.randint(0, len(available_grades) - 1)] courses_ins.append(copied_list[j - 1]) image_ins = img_urls[random.randint(0, len(img_urls) - 1)] student_list.append( student( name=name_ins, gender=gender_ins, data_sheet=data_sheet(courses=courses_ins), image_url=image_ins, )) return student_list
def test_hash(): hashStudent = student() print hash(hashStudent) name = 'amy' GPA = 3.4 age = 16 print hash(hashStudent) hash2Student = student(name,GPA,age) hash3Student = student(name,GPA,age) if(hash2Student == hash3Student): assert (hash(hash2Student) == hash(hash3Student)) if(not hashStudent == hash2Student): assert (not hash(hashStudent) == hash(hash2Student)) print hash(hash2Student) print hash(hash3Student) print 'Hash test done!'
def changestudent(filepath): with open(filepath, 'r') as fi: studentlist = [] for line in fi: stuinfo = line.strip().split() stu = student.student(stuinfo[0], int(stuinfo[1]), int(stuinfo[2])) studentlist.append(stu) if len(studentlist) == 0: print("no student info.") return id = input("input student id:") idx = utils.searchstudentid(studentlist, int(id)) while idx >= len(studentlist): id = input("input student id:") idx = utils.searchstudentid(studentlist, int(id)) grade = input("input the grade:") while not utils.checkgrade(grade): grade = input("input the right grade:") studentlist[idx][2] = grade instruct = input('save:(y/n)') if instruct.lower() == 'y': with open(filepath, 'w') as fi: for stu in studentlist: fi.write(str(stu) + '\n') print("save succesful.")
def delstudent(filepath): with open(filepath, 'r') as fi: studentlist = [] for line in fi: stuinfo = line.strip().split() stu = student.student(stuinfo[0], int(stuinfo[1]), int(stuinfo[2])) studentlist.append(stu) if len(studentlist) == 0: print("no student info.") return id1 = input("input id:") idx = utils.searchstudentid(studentlist, int(id1)) while idx >= len(studentlist): id1 = input("none of this id,input the right id:") idx = utils.searchstudentid(studentlist, int(id1)) instruct = input("confirm:(y/n)") if instruct.lower() == "y": del studentlist[idx] with open(filepath, 'w') as fi: for stu in studentlist: fi.write(str(stu) + '\n') print("save succesful.")
def jump(): global name reg = Gui() if re.match("S", name): student(reg, mysql, name) gui.close() elif re.match("T", name): teacher(reg, mysql, name) gui.close() elif re.match("W", name): worker(reg, mysql, name) gui.close() elif re.match("M", name): manager(reg, mysql, name) gui.close() gui.close()
def login(): """ 登陆模块 :return: """ login_status = 0 user_name = input("请输入用户名:").strip() user_pwd = input("请输入密码:").strip() hash = hashlib.md5() hash.update(bytes(user_pwd, encoding='utf-8')) with open(r'../data/info.txt', 'r', encoding='utf-8') as f: ret = f.readline() while ret: ret = ret.strip('\n') ret = eval(ret) if user_name == ret['name']: if str(hash.hexdigest()) == ret['passwd']: print("登陆成功") # 登录写入日志 with open('../log/login.txt', mode='a', encoding='utf-8') as f1: f1.write( "{} 用户{}登录成功了\n".format( time.strftime("%Y-%m-%d %X"), user_name)) if ret['level'] == 1: user1 = student.student( ret['name'], ret['passwd'], ret['level'], ret['subject'], ret['class_grade'], ret['lecturer']) login_status = 1 return user1, login_status elif ret['level'] == 2: user1 = teacher.teacher( ret['name'], ret['passwd'], ret['level'], ret['subject'], ret['class_grade'], ret['lecturer']) login_status = 1 return user1, login_status else: user1 = admin.admin( ret['name'], ret['passwd'], ret['level'], ret['subject'], ret['class_grade'], ret['lecturer']) login_status = 1 return user1, login_status ret = f.readline() if login_status == 0: print('用户不存在或者密码错误') return [], 0
def checks(name, password): conn = db.connect('login.db') cur = conn.cursor() if (cur.execute('SELECT * FROM user WHERE name =? AND password = ?', (name, password))): if cur.fetchone(): window = Tk() window.title('Student_User') window.geometry('700x450') student.student(window) window.mainloop() else: messagebox.showinfo('error:', 'INVALID CREDENTIALS for STUDENT LOGIN') conn.commit() conn.close()
def fileread(filepath): with open(filepath, 'r') as fi: studentlist = [] for line in fi: stuinfo = line.strip().split() stu = student.student(stuinfo[0], int(stuinfo[1]), int(stuinfo[2])) studentlist.append(stu) return studentlist
def get_random_student(id): fake = faker.Faker() name = names.get_full_name() first_last = name.lower().split(' ') email = first_last[0][0] + '.' + first_last[1] + '@innopolis.ru' address = fake.address().replace('\n', ' ') return student(id, name, email, address)
def test_str(): name = 'student' GPA = 0.0 age = 16 amyStudent = student() d = "{'age': " + str(age) + ", 'name': '" + name + "', 'GPA': " + str(GPA) + "}" print d print amyStudent assert str(amyStudent) == d name = '1' GPA = 1.0 age = 2 amyStudent = student(name,GPA,age) d = "{'age': " + str(age) + ", 'name': '" + name + "', 'GPA': " + str(GPA) + "}" print d print amyStudent assert str(amyStudent) == d print 'String test done!'
def parse_file(self, f): with open(f, 'r') as csvfile: lineReader = csv.reader(csvfile, delimiter=',') for line in lineReader: fn = str(line[0]) #first name ln = str(line[1]) #last name em = str(line[2]) #email new_student = student(" ".join([fn, ln]), em) self.listOfStudents.append(new_student)
def make_students_dict(students, course, assignment, reviews, rubric): students_dict = {} for s in students: students_dict[s.id] = (student(s.id, course, assignment, s.name, s.login_id)) submissions_dict = make_submissions_dict(assignment) update_peer_reviews(reviews, students_dict, course, submissions_dict, rubric) return students_dict
def separa_generos(list_students): list_male = [] list_female=[] for student in list_students: if student.gender==m: list_male.append(student()) return list_male
def recv_reply(self, cour): try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('192.168.5.103', 2000)) s.listen(10) print("Wait") self.course_connect_status.setText("已连接客户端!") def recvall(sock, count): buf = b'' # buf是一个byte类型 while count: # 接受TCP套接字的数据。数据以字符串形式返回,count指定要接收的最大数据量. newbuf = sock.recv(count) if not newbuf: return None buf += newbuf count -= len(newbuf) return buf sock, addr = s.accept() # print('connect from:' + str(addr)) while True: length = recvall(sock, 16) # 获得图片文件的长度,16代表获取长度 stringData = recvall(sock, int(length)) # 根据获得的文件长度,获取图片文件 data = numpy.frombuffer(stringData, numpy.uint8) # 将获取到的字符流数据转换成1维数组 decimg = cv2.imdecode(data, cv2.IMREAD_COLOR) # 将数组解码成图像 name_result = identification(decimg) stu = student(name_result, getInfo(name_result)['id'], getInfo(name_result)['class'], getInfo(name_result)['major']) # print('识别结果:' + name_result) # print(getInfo(name_result)) if name_result != 'Unknown': cour.sign(stu) self.sign_in.setText(','.join(cour.display_singIn())) self.sign_in.setFont(QFont("微软雅黑", 10, QFont.Bold)) self.sign_out.setText(','.join(cour.display_singOut())) self.sign_out.setFont(QFont("微软雅黑", 10, QFont.Bold)) displayInfo(identification(decimg), sock) name_stu = name_result.encode('utf-8') sock.send(name_stu) id_stu = str(getInfo(name_result)['id']).encode('utf-8') sock.send(id_stu) class_stu = str(getInfo(name_result)['class']).encode('utf-8') sock.send(class_stu) major_stu = getInfo(name_result)['major'].encode('utf-8') sock.send(major_stu) break sock.close() s.close() except socket.error as msg: print(msg)
def setUp(self): grades = { "Math": 80, "English": 85, "Science": 59, "Agriculture": 75, "Art,Craft & Music": 82 } name = "Mark" grade = "Grade 8" unittest.TestCase.setUp(self) self.student = student(name, grades, grade)
def add_account(self): """ 创建学生用户 """ student_name = input("请输入学生的用户名:").strip() student_passwd = input("请输入学生的密码:").strip() new_account = student(student_name, student_passwd, 1) new_account.save_info() # 创建学生用户写入日志 with open('../log/add_user_log.txt', mode='a', encoding='utf-8') as f3: f3.write("{}学生用户{}创建成功\n".format(time.strftime("%Y-%m-%d %X"), student_name)) print("学生账户创建成功")
def get(self, key): print(self._lengths) f = open(self._filename, 'r+') prev = self._page_offset + self._data_offset for length in self._lengths: f.seek(prev) record_str = f.read(length) id = int(record_str[:3]) if (id == key): f.close() return student(to_parse=record_str) prev += length f.close()
def main(): emp1 = person("Jennifer", "Jones", "4/6/1964", "4601 Mid Rivers Mall Dr.", "Cottleville", "MO", "63376") emp2 = employee("Rex", "McKanry", "1/1/1900", "4602 River Dr.", "St. Peters", "MO", "63366", "1007", "Computer Science", "Engineering and Technology") student1 = person("John", "Smith", "1/24/1990", "4603 Mid Ribbit Lane", "St. Charles", "MO", "63309") student2 = student("Jonah", "Smiles", "10/31/1990", "1409 Skeleton Key Road", "Lake St. Louis", "MO", "63313", "Computer Science", "Cybersecurity", "4.0", "Senior") student3 = employee("Jimmy", "Neutron", "12/31/1999", "13 Neutron Lane", "St. Einstein Ave.", "MO", "63078", "1313", "Science", "Chemistry") print(emp1) print(emp2) print(student1) print(student2) print(student3)
def enterStudent(): file = open("student.bin", "ab+") IDstorage = open("StuId.bin", "ab+") id = int(pickle.load(IDstorage)) id += 1 # book=books.book(id) student = students.student(id) student.setStudent() pickle.dump(student, file) IDstorage.close() IDstorage = open("StuId.bin", "wb+") pickle.dump(id, IDstorage) IDstorage.close()
def addStudent(self, name, subject): try: index = str(name).find(".") name = name[:index] student = st.student(name, subject) found = student in self.students if not found: self.students.append(student) return student except Exception: print(Exception) return None
def core(): studentData = student(input("Write your name: "), input("Write your grade (e.g 1st, 2nd..): "), input("Write your teacher's name: "), input("Write your school's name: ")) language = input( "Write the language code of your research: (supported codes: en (english), pt(portuguese)): " ) theme = input("Write the theme of your homework research: ") searchData = search(theme, language) images(theme) msword(studentData.getHeader(), theme, searchData['content'].split('\n'), '../downloads') print('Your homework is done!!!')
def crea_estudiantes(count_estudiantes): count = 0 list_students = [] while count < int(count_estudiantes): student_code = input("Escribe el número de matricula: ") student_name = input("Escribe el nombre: ") student_age = input("Escribe la edad: ") student_gender = input("Escribe el genero (M ó H): ") student_carreer = input("Escribe la carrera a la que pertenece: ") list_students.append(student(student_code,student_name,student_age,student_gender,student_carreer)) count = count + 1 return list_students
def students_from_file(input_file): """ Checks for line prefixes which are variables in the student object """ student_list = [] cList = [] student_placeholder = {} courses_placeholder = {} lines = [line.rstrip("\n") for line in open(input_file)] for line in lines: if "____" in line: student_list.append( student( name=student_placeholder["name"], data_sheet=data_sheet(courses=cList.copy()), gender=student_placeholder["gender"], image_url=student_placeholder["image_url"], )) student_placeholder.clear() cList.clear() elif "name: " in line and not "_name" in line: student_placeholder["name"] = " ".join(line.split()[1:]) elif "gender: " in line: student_placeholder["gender"] = " ".join(line.split()[1:]) elif "course_name: " in line: courses_placeholder["name"] = " ".join(line.split()[1:]) elif "teacher" in line: courses_placeholder["teacher"] = " ".join(line.split()[1:]) elif "ects" in line: courses_placeholder["ECTS"] = " ".join(line.split()[1:]) elif "grade" in line: courses_placeholder["optional_grade"] = " ".join(line.split()[1:]) if courses_placeholder: cList.append( course( name=courses_placeholder["name"], teacher=courses_placeholder["teacher"], ECTS=courses_placeholder["ECTS"], optional_grade=courses_placeholder["optional_grade"], class_room=courses_placeholder["class_room"], )) courses_placeholder.clear() elif "classroom" in line: courses_placeholder["class_room"] = " ".join(line.split()[1:]) elif "img_url" in line: student_placeholder["image_url"] = " ".join(line.split()[1:]) return student_list
def crea_estudiantes(count_estudiantes): count = 0 list_students = [] while count < int(count_estudiantes): student_code = input("dame la matricula: ") student_name = input("dame el nombre: ") student_age = input("dame la edad: ") student_gender = input("dame el genero: ") student_carreer = input("dame la carrera: ") list_students.append(student(student_code,student_name,student_age,student_gender,student_carreer)) count = count + 1 return list_students
def checks(name,password):# for student login conn=sqlite3.connect('lms.db') cur = conn.cursor() if (cur.execute('SELECT * FROM user WHERE name = ? AND password = ?', (name, password))): if cur.fetchone(): window = Tk() window.title('Student') window.geometry('700x400') obj = student(window) window.mainloop() else: messagebox.showinfo('error','Invalid details for student login') conn.commit() conn.close()
def issue_book(self, bookName, studentID, studentName, studentContact): found = False studentObject = student(studentName, studentID, studentContact) self.student_list.append(studentObject) for book in self.book_list: if book.get_book_name() == bookName: if book.get_book_quantity() == 0: print("Sorry, All copies are Issued") return found = True book.set_studentIssue(studentObject) book.decrement_book_quantity() self.issued_books_list.append(book) print('Book Issued Successfully') if found == False: print("Not Found")
def loginWindow(): root = login.Login() root.update() root.mainloop() if (login.Login.user == "admin"): window = admin.admin() window.update() window.mainloop() elif (login.Login.user == "student"): window = student.student() window.update() window.mainloop() login.Login.user = "******" if (login.Login.userloggedout): loginWindow()
def main(): # fill out the main function # 1. Read the Input File # 2. Make the student instance for each student # 3. Print name, score, grade with using __repr__ # 4. Write the outpuf File input_file = open("student_scores.txt", "r") output_file = open("grading_result.txt", "w") for line in input_file.readlines(): s = student(*line.rstrip().split(",")) print(s) output_file.write("{},{:.2f},{}\n".format(s.name, s.calculate_total_score(), s.get_total_grade())) input_file.close() output_file.close()
def __init__(self): QMainWindow.__init__(self) self.setupUi(self) self.db = Model() self.tabes_data = { u'حضور الطلاب': student_enter(), u'الطالب': student(), u'المجموعات': course(), u'الاختبارات': exam(), u'تقرير المجموعات': Report_all(), u'تقرير الطالب': st_report(), u'تقرير الماليه': report(), u'المستخدمين': permissions() } for i in self.findChildren(QWidget): i.setAttribute(Qt.WA_StyledBackground, True) for i in self.widget_3.findChildren(QToolButton): i.clicked.connect(self.pr_lst) self.h.tabCloseRequested.connect(self.removeTab) self.h.currentChanged.connect(self.tab_select)
def get_student_by_id(db_conn, id): cursor = db_conn.cursor() query = ''' SELECT s.student, s.first_name, s.last_name FROM tb_student s WHERE s.student = %(id)s AND s.disabled = FALSE ''' cursor.execute(query, {"id":id}) rows = cursor.fetchall() if len(rows) > 1: raise ValueError, "IDs are not unique (this shouldn't be allowed by the schema)" if len(rows) < 1: raise ValueError, "Student with that id does not exist: %s" % (id) return student.student(rows[0][0], rows[0][1], rows[0][2])
def getStudents() : students = [] dump = [] #open the file with open("sample_students.txt") as file: for line in file: currentline = (line.rstrip("\n")).split(","), dump.append(currentline) # go over the rows of the data dump for x in range(len(dump)): #if the current row's first term is 0, #it's a new student so create a new student object if (dump[x][0][0] == "0"): new_semesters = [] # variable to track when to stop adding data to the new student object y = 1 while ((x+y) < len(dump) and dump[x+y][0][0] != "0"): #variable to store courses curCourses = [] #loop over a semester for z in range(int((len(dump[x+y][0]) - 1) / 4)): curCourses.append(course.course(clean(dump[x+y][0][4 * z + 1]), int(dump[x+y][0][4 * z + 2]), int(dump[x+y][0][4 * z + 3]), int(dump[x+y][0][4 * z + 4]))) #add the semester into the array of semesters sem = semester.semester(curCourses) new_semesters.append(sem) y = y + 1 #create a new student object new_student = student.student(dump[x][0][2], new_semesters, dump[x][0][1], "") students.append(new_student) return students
#!/usr/bin/env python # -*- coding: utf-8 -*- from student import student from types import MethodType # 根据开比原则,不要随意更改一个类的内容 def set_age(self, age): self.real_age = age stu=student('Zhangsan', 20) stu2=student('Lisi', 25) print stu.get_age() print stu.get_name() # 1.方法的动态绑定 stu.set_age = MethodType(set_age, stu, student) stu.set_age(32) # print stu.__dict__ print stu.get_age() print stu.real_age # 'student' object has no attribute 'set_age' # 2.但是,给一个实例绑定的方法,对另一个实例是不起作用的: # stu2.set_age(33) # 3.为了给所有实例都绑定方法,可以给class绑定方法 student.set_age = MethodType(set_age, None, student) stu2.set_age(22)
def to_ical(self,year): gc = ical.ICal() return student.student(self,year,gc)
def to_gcal(self,year): gc = gcal.GCal() return student.student(self,year,gc)
def setUp(self): grades = {"Math": 80, "English": 85, "Science": 59, "Agriculture":75, "Art,Craft & Music": 82} name = "Mark" grade = "Grade 8" unittest.TestCase.setUp(self) self.student = student(name, grades, grade)
temp = [] for line in lecturersText: x = [] x = line.split(";") x[-1] = x[-1].rstrip() temp.append(x) for lecturers in temp: y = lecturer(lecturers[0],lecturers[1],lecturers[2],lecturers[3]) listOfQuestions.append(y) with open("data/students.txt") as studentsText: temp = [] for line in studentsText: x = [] x = line.split(";") x[-1] = x[-1].rstrip() temp.append(x) for students in temp: y = student(students[0],students[1],students[2],students[3]) listOfStudents.append(y) with open("data/lessons.txt") as lessonsText: temp = [] for line in lessonsText: x = [] x = line.split(";") x[-1] = x[-1].rstrip() temp.append(x) for lessons in temp: y = lesson(lessons[0],lessons[1],lessons[2],lessons[3]) listOfQuestions.append(y)
def __init__(self, path, que_list): self.stud_list = [student(basename(f), f, que_list) for f in listdir(path, is_dir=True, full_path=True)] self.stud_list.sort()
from student import student grades = {'Math': 80, 'English': 85, 'Science': 80, 'Agriculture':75, 'Art,Craft & Music': 82} student = student('Mark', grades, 'Male') print student.getStudentInfo() print "\n\n\n" print student.getGrades()
from student import student fivestudents = [student('brad',2.0,13),student('lisa',3.4,10),student('bob',2.0,11),student('brad',2.0,12),student('susan',3.4,14)] mystudent = student('Joe',3.4,5) for student in fivestudents: print str(student) print '\n' fivestudents.sort(key=lambda student:student['age']) fivestudents.sort(key=lambda student:student['name']) fivestudents.sort(key=lambda student:student['GPA']) for students in fivestudents: print students
def trysorting(): c3student = student('c',3.0,6) c2student = student('c',3.0,7) astudent = student('a',1.0,1) F3student = student('F',1.0,3) Fstudent = student('F',1.0,1) bstudent = student('b',4.0,2) Estudent = student('E',3.8,4) cstudent = student('c',3.0,6) Dstudent = student('D',3.0,3) dstudent = student('d',2.5,9) Cstudent = student('C',2.5,4) a2student = student('a',2.5,9) estudent = student('e',1.6,3) Bstudent = student('B',4.0,11) fstudent = student('f',3.3,5) Astudent = student('f',1.5,12) studentlist = list() studentlist.append(c3student) studentlist.append(c2student) studentlist.append(astudent) studentlist.append(F3student) studentlist.append(Fstudent) studentlist.append(bstudent) studentlist.append(Estudent) studentlist.append(cstudent) studentlist.append(Dstudent) studentlist.append(dstudent) studentlist.append(Cstudent) studentlist.append(a2student) studentlist.append(estudent) studentlist.append(Bstudent) studentlist.append(fstudent) studentlist.append(Astudent) sortedlist = sorted(studentlist) sortedcheck = list() sortedcheck.append(Fstudent) sortedcheck.append(F3student) sortedcheck.append(astudent) sortedcheck.append(Astudent) sortedcheck.append(estudent) sortedcheck.append(Cstudent) sortedcheck.append(a2student) sortedcheck.append(dstudent) sortedcheck.append(Dstudent) sortedcheck.append(c3student) sortedcheck.append(cstudent) sortedcheck.append(c2student) sortedcheck.append(fstudent) sortedcheck.append(Estudent) sortedcheck.append(Bstudent) sortedcheck.append(bstudent) assert str(sortedlist) == str(sortedcheck) newstudentlist = studentlist[:] newstudentlist.sort(key=lambda student:student['age']) newstudentlist.sort(key=lambda student:student['name']) newstudentlist.sort(key=lambda student:student['GPA']) assert str(newstudentlist) == str(sortedcheck) print 'Sorting Test Done!'
def test_lt(): ltstudent = student('amy',2.0,5) ltstudent2 = student('joe',2.0,10) assert (ltstudent < ltstudent2) == True ltstudent = student('amy',2.0,5) ltstudent2 = student('amy',2.0,5) assert (ltstudent < ltstudent2) == False ltstudent = student('Joe',3.0,5) ltstudent2 = student('joe',3.0,5) assert (ltstudent < ltstudent2) == True ltstudent = student('amy',2.0,10) ltstudent2 = student('amy',2.0,5) assert (ltstudent < ltstudent2) == False ltstudent = student('amy',3.0,5) ltstudent2 = student('joe',2.0,10) assert (ltstudent < ltstudent2) == False ltstudent = student('amy',3.0,10) ltstudent2 = student('joe',2.0,5) assert (ltstudent < ltstudent2) == False ltstudent = student('amy',3.0,5) ltstudent2 = student('joe',2.0,5) assert (ltstudent < ltstudent2) == False ltstudent = student('amy',2.0,5) ltstudent2 = student('joe',3.0,10) assert (ltstudent < ltstudent2) == True ltstudent = student('amy',2.0,10) ltstudent2 = student('joe',3.0,5) assert (ltstudent < ltstudent2) == True ltstudent = student('joe',2.0,10) ltstudent2 = student('joe',3.0,5) assert (ltstudent < ltstudent2) == True ltstudent = student('Joe',2.0,10) ltstudent2 = student('joe',3.0,5) assert (ltstudent < ltstudent2) == True print 'Less than test done!'
def submit(event): global photo global this_is_main_part who = int(v.get()) if who == 0: print(showerror('ShowError', 'Please Select Admin Or Student')) llll = len(entry_1.get()) entry_1.delete(0, llll) llll = len(entry_2.get()) entry_2.delete(0, llll) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) elif who == 1: if entry_1.get() != '': if entry_2.get() != '': query = "select * from admin where username=\'" + str( entry_1.get()) + "\' " cursor.execute(query) all_details = cursor.fetchall() if len(all_details) <= 0: query = "select * from librarian where username=\'" + str( entry_1.get()) + "\' " cursor.execute(query) all_details = cursor.fetchall() if len(all_details) > 0: query = "select * from admin where username=\'" + str( entry_1.get()) + "\' and password= \'" + str( entry_2.get()) + "\' " cursor.execute(query) all_details = cursor.fetchall() if len(all_details) <= 0: query = "select * from librarian where username=\'" + str( entry_1.get( )) + "\' and password= \'" + str( entry_2.get()) + "\' " cursor.execute(query) all_details = cursor.fetchall() if len(all_details) > 0: if entry_3.get() != '': if str(entry_3.get()) == str( this_is_main_part): all_details = all_details[0] t.destroy() admin(all_details[0], all_details[1]) else: entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) else: showwarning('Warning', 'Please Write The Captcha') this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) else: print( showerror('ShowError', 'Please Enter Right Password')) llll = len(entry_2.get()) entry_2.delete(0, llll) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) else: print( showerror('ShowError', 'Please Enter valid username')) llll = len(entry_1.get()) entry_1.delete(0, llll) llll = len(entry_2.get()) entry_2.delete(0, llll) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) else: print(showerror('ShowError', 'Please Enter Password')) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) else: print(showerror('ShowError', 'Please Enter Username')) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) elif who == 2: if entry_1.get() != '': if entry_2.get() != '': query = "select * from student where enrollment_no=\'" + str( entry_1.get()) + "\' " cursor.execute(query) all_details = cursor.fetchall() if len(all_details) > 0: query = "select * from student where enrollment_no=\'" + str( entry_1.get()) + "\' and password= \'" + str( entry_2.get()) + "\' " cursor.execute(query) all_details = cursor.fetchall() if len(all_details) > 0: if entry_3.get() != '': if str(entry_3.get()) == str( this_is_main_part): all_details = all_details[0] t.destroy() student(all_details[0], all_details[6]) else: entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) this_is_main_part = generate_captcha() this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) else: showwarning('Warning', 'Please Write The Captcha') this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) else: print( showerror('ShowError', 'Please Enter Right Password')) llll = len(entry_2.get()) entry_2.delete(0, llll) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) else: print( showerror('ShowError', 'Please Enter valid username')) llll = len(entry_1.get()) entry_1.delete(0, llll) llll = len(entry_2.get()) entry_2.delete(0, llll) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) else: print(showerror('ShowError', 'Please Enter Password')) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) else: print(showerror('ShowError', 'Please Enter Username')) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) elif who == 3: if entry_1.get() != '': if entry_2.get() != '': query = "select * from librarian where username=\'" + str( entry_1.get()) + "\' " cursor.execute(query) all_details = cursor.fetchall() if len(all_details) > 0: query = "select * from librarian where username=\'" + str( entry_1.get()) + "\' and password= \'" + str( entry_2.get()) + "\' " cursor.execute(query) all_details = cursor.fetchall() if len(all_details) > 0: all_details = all_details[0] t.destroy() admin(all_details[0], all_details[1]) else: print( showerror('ShowError', 'Please Enter Right Password')) llll = len(entry_2.get()) entry_2.delete(0, llll) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) else: print( showerror('ShowError', 'Please Enter valid username')) llll = len(entry_1.get()) entry_1.delete(0, llll) llll = len(entry_2.get()) entry_2.delete(0, llll) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) else: print(showerror('ShowError', 'Please Enter Password')) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get())) else: print(showerror('ShowError', 'Please Enter Username')) this_is_main_part = generate_captcha() photo = PhotoImage(file='shyam.png') Button(t, width=190, bg='#BDB76B', fg='black', command=papa, cursor='hand2', image=photo).place(x=230, y=210) entry_3.delete(0, len(entry_3.get())) entry_1.delete(0, len(entry_1.get())) entry_2.delete(0, len(entry_2.get()))
import student stu = student.student("jason", 30) stu.desc() print(stu.name) print(stu.age)