Advertisement
ridleygarnier

Untitled

Feb 19th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. def make_grouping(self, course: Course, survey: Survey) -> Grouping:
  2.         """
  3.        Return a grouping for all students in <course>.
  4.  
  5.        The first group should contain the students in <course> whose names come
  6.        first when sorted alphabetically, the second group should contain the
  7.        next students in that order, etc.
  8.  
  9.        All groups in this grouping should have exactly self.group_size members
  10.        except for the last group which may have fewer than self.group_size
  11.        members if that is required to make sure all students in <course> are
  12.        members of a group.
  13.  
  14.        Hint: the sort_students function might be useful
  15.        """
  16.         students = list(course.get_students())
  17.         students_sorted = slice_list((sort_students(students, 'name')),
  18.                                      self.group_size)
  19.         final = Grouping()
  20.  
  21.         for lst in students_sorted:
  22.             x = Group(lst)
  23.             final.add_group(x)
  24.         return final
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement