def add_student(form_id, full_name, sex) -> Student: student = Student() student.full_name = full_name student.sex = sex student.save() form = Form.objects(id=form_id).first() form.Student_ids.append(student.id) form.save() return student
help(hello.upper) # Evaluate python code in String format. print() command = 'print("Hello")' eval(command) # Execute python code in String format (ideal for multiple lines of code). print() command = 'print("Hello")' exec(command) # Changing data types. print() a = 1 print(str(a) + str(a)) print(float(a) + float(a)) print(int(a) + int(a)) print(str(a)) """ OBJECT-ORIENTED PROGRAMMING """ # Class and object print("\nOBJECT-ORIENTED PROGRAMMING:") p = Person("Joseph", "Grech", 29) print("%s %s is %d years old." % (p.getFirstName(), p.getLastName(), p.getAge())) # Inheritance s = Student("Joseph", "Grech", 29, "Python") print("%s %s is %d years old, and is reading a %s course." % (s.getFirstName(), s.getLastName(), s.getAge(), s.getCourse()))