0

Create relationships

an school with 2 teachers(a,b) and a has 3 students(1,2,3) and b has 2 students(4,5). how we can write a code to make this school and make link between teachers and their students. finally we want print each teacher name with his students. and how delete / add teacher and student???? please help meeeeee

15th Feb 2017, 6:42 PM
hamid
hamid - avatar
12 Antworten
+ 1
Well, you can create a student class with teacher field and overloaded __repr__ method: class Student: def __init__(self, name, teacher): self.name = name self.teacher = teacher def __repr__(self): return self.name + ' ' + self.teacher
17th Feb 2017, 4:43 AM
DotJason
+ 1
thanks, can you define two teachers and five students in this code?
17th Feb 2017, 8:06 AM
hamid
hamid - avatar
+ 1
students = [ Student("John", "a"), Student("Rose", "a"), Student("Dave", "a"), Student("Jane", "b"), Student("Jake", "b")) ]
17th Feb 2017, 2:16 PM
DotJason
0
dear DotJason I would like to write a application that is important for me, and its my first application, if you have time I can explain to you about this application, I think if you help me this will not be my last app.
17th Feb 2017, 4:32 PM
hamid
hamid - avatar
0
Well, it would be nice if you would provide some social network contacts or messengers you use (because chatting here is a mess)
17th Feb 2017, 4:35 PM
DotJason
0
thanks, skype is ok?
17th Feb 2017, 4:39 PM
hamid
hamid - avatar
0
Yeah, I think so
17th Feb 2017, 4:39 PM
DotJason
0
so give me your id or number
17th Feb 2017, 4:42 PM
hamid
hamid - avatar
0
+79258939392
17th Feb 2017, 4:46 PM
DotJason
0
what ur country??
17th Feb 2017, 4:59 PM
hamid
hamid - avatar
0
Russia (and I'm serious) (and I'm not a hacker)
17th Feb 2017, 5:04 PM
DotJason
0
can u add me hamid.mohammadi30@hotmail.com
17th Feb 2017, 5:04 PM
hamid
hamid - avatar