Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
bacs_class
#python 2.7.12 # THE CLASS STARTS BEING DEFINED HERE class bacs_class: def __init__(self, name, teacher, room, schedule_block): self.name = name self.teacher = teacher self.room = room # the schedule block will be either A-Block, B-Block, C-Block # D-Block, E-Block, 1st-lunch, 2nd-lunch, Tue-CIP, and Thu-CIP self.schedule_block = schedule_block self.students = [] self.homework = {} self.classwork = {} def set_teacher(self, teacher): self.teacher = teacher def get_teacher(self): return self.teacher def get_class_size(self): return len(self.students) def add_student(self, name): self.students.append(name) def remove_student(self, name): self.students.remove(name) def add_classwork(self, name, description): self.classwork[ name ] = description def remove_classwork(self, name): del(self.classwork[name]) ##### # 6 METHODS TO DEFINE: #def set_room(): #def get_room(): #def set_schedule_block(): #def get_schedule_block(): #def add_homework(): #def remove_homework(): ##### def print_class_info(self): print(self.name + " meets in " + self.room + " and is taught by " + self.teacher + " during " + self.schedule_block) print("") def print_students(self): print("there are currently " + str(self.get_class_size()) + " students enrolled: ") print(self.students) print("") def print_classwork(self): print("here are the classwork assignments") print(self.classwork) print("") def print_homework(self): print("here are the homework assignments") print(self.homework) print("") ### THIS IS THE END OF THE CLASS # HERE WE ARE USING THE bacs_class CLASS TO CREATE AN OBJECT REPRESENTING # OUR CLASS varsity_coding = bacs_class("Varsity Coding", "Paul P.", "Room 206", "Tue-CIP") varsity_coding.add_student("Haley") varsity_coding.add_student("Dylan") varsity_coding.add_student("Jason") varsity_coding.add_student("Katie") varsity_coding.add_student("Ariana Grande") varsity_coding.add_classwork("Code Sample #1", "Analyze the code sample and tell us what it does") varsity_coding.add_classwork("Code Sample #2", "Begin Working With Lists") varsity_coding.print_class_info() varsity_coding.print_students() varsity_coding.print_classwork() # THERE ARE 3 PARTS TO THIS ASSIGNMENT # # 1) DEFINE THE 6 METHODS (FUNCTIONS) THAT ARE LISTED IN THE COMMENTS BUT NOT DEFINED # # 2) USE THE varsity_coding OBJECT'S METHODS SO THAT THE OBJECT HAS THE CORRECT INFO: # - THE RIGHT CLASS MEMBERS # - THE CORRECT SCHEDULE BLOCK # - THE CORRECT ROOM NUMBER # # 3) IN THE SAME WAY THAT WE CREATED THE varsity_coding OBJECT TO MODEL OUR CLASS # CREATE ANOTHER OBJECT CALLED my_advisory TO CORRECTLY MODEL YOUR ADVISORY # YOU DON'T NEED TO ADD ANY CLASSWORK / HOMEWORK FOR IT, BUT MAKE SURE YOU CALL THE # print_class_info and print_students METHODS SO I CAN SEE THAT # IT CORRECTLY MODELS YOUR ADVISORY
run
|
edit
|
history
|
help
0
asxsd
ab
espacio_blanco
python2 - division - 0
test
Shabnam_name_checker
Python
Printing
information of operating system on which your code is run
PyPartial