Python Mock Teacher classes class

Source: Internet
Author: User

1 #-*-coding:utf-8-*-2 Import Time3 4 classPerson (object):5     " "6 define Parent class: People7 Properties: Name, age8 method: Walk (Print: name + "Walking")9     " "Ten       One     def __init__(self, Name, age): ASelf.name =name -Self.age = Age -  the     defWalk (self): -         PrintSelf.name +"is walking" -  -  + classTeacher (person): -     " " + definition Subclass: Teacher A Properties: Class Students (collection) at method: Teach (Print: Name + "Teacher is in class", and call all class students to listen to the method) - class dismissed (print: "Class dismissed" and call all students on the way to walk) -     " " -     #method overload (name), overriding the parent class initial value -     def __init__(Self,name,age, students): -Person.__init__(self, name, age) inSelf.students =Students -  to     defTeach (self): +         PrintSelf.name +"The teacher is having a class" -          forIinchself.students: the I.learn () *  $     defClassover (self):Panax Notoginseng         Print "class" -          forIinchself.students: the I.walk () +  A  the classStudent (person): +     " " - defining subclasses: Students $ Properties: Study number $ method: Lectures (Print: Name + School Number + "listening class") -     " " -     def __init__(self, Name,age, StudentID): thePerson.__init__(self, name, age) -Self.studentid =StudentIDWuyi  the     defLearn (self): -         PrintSelf.name + str (self.studentid) +"I 'm listening ." Wu  -  About if __name__=="__main__": $  -     #instantiate a teacher, three students, then mock the teacher class, the teacher dismissed the scene -Studentlist = [Student ("A", 07150200), Student ("B", 07150232), Student ("C", 19, 07150266)] -Teacher = Teacher ("Pzj", 20, Studentlist) A Teacher.teach () +     Print '-'* 10,"waiting for class .",'-'*10 theTime.sleep (5) -Teacher.classover ()

Python Mock Teacher classes class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.