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
12 Answers
+ 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
+ 1
thanks, can you define two teachers and five students in this code?
+ 1
students = [
Student("John", "a"),
Student("Rose", "a"),
Student("Dave", "a"),
Student("Jane", "b"),
Student("Jake", "b"))
]
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.
0
Well, it would be nice if you would provide some social network contacts or messengers you use (because chatting here is a mess)
0
thanks, skype is ok?
0
Yeah, I think so
0
so give me your id or number
0
+79258939392
0
what ur country??
0
Russia (and I'm serious) (and I'm not a hacker)
0
can u add me hamid.mohammadi30@hotmail.com