One way to put a list of people into teams is by counting off. For example, if the list of people is: ['paul', 'francois', 'andrew', 'sue', 'steve', 'arnold', 'tom', 'danny', 'nick', 'anna', 'dan', 'diane', 'michelle', 'jeremy', 'karen'] and the number of teams desired is four, then you assign the people to teams 0, 1, 2, 3, 0, 1, 2, 3, etc. like this: [['paul', 'steve', 'nick', 'michelle'], ['francois', 'arnold', 'anna', 'jeremy'], ['andrew', 'tom', 'dan', 'karen'], ['sue', 'danny', 'diane']] Write the code for the following function. Do not assume that the list of people will divide evenly into the desired number of teams. If the list of people does not divide evenly into the desired number of teams, the teams will simply have unequal sizes. Do not assume that the number of people is at least as large as the number of teams. If there aren't enough people to cover the teams, some (or even all) teams will simply be empty. Hint: The range function will be very helpful. def form_teams (people: list [str], num_teams: int) ->\ list [list [str]]: num_teams is guaranteed to be >= 1. Return a list of lists of names from counting off. Each sublist represents a team. # Your code here

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 14PE
icon
Related questions
Question
One way to put a list of people into teams is by counting off. For example, if the list of people is:
['paul', 'francois', 'andrew', 'sue', 'steve',
'arnold', 'tom', 'danny', 'nick', 'anna', 'dan',
'diane', 'michelle', 'jeremy', 'karen']
and the number of teams desired is four, then you assign the people to teams 0, 1, 2, 3, 0, 1, 2, 3, etc. like this:
[['paul', 'steve', 'nick', 'michelle'],
['francois', 'arnold', 'anna', 'jeremy'],
['andrew', 'tom', 'dan', 'karen'],
['sue', 'danny', 'diane']]
Write the code for the following function. Do not assume that the list of people will divide evenly into the desired
number of teams. If the list of people does not divide evenly into the desired number of teams, the teams will simply
have unequal sizes. Do not assume that the number of people is at least as large as the number of teams. If there
aren't enough people to cover the teams, some (or even all) teams will simply be empty. Hint: The range function
will be very helpful.
def form_teams (people: list[str], num_teams: int) ->\
list [list [str]]:
num_teams is guaranteed to be >= 1.
Return a list of lists of names from counting off.
Each sublist represents a team.
# Your code here
Transcribed Image Text:One way to put a list of people into teams is by counting off. For example, if the list of people is: ['paul', 'francois', 'andrew', 'sue', 'steve', 'arnold', 'tom', 'danny', 'nick', 'anna', 'dan', 'diane', 'michelle', 'jeremy', 'karen'] and the number of teams desired is four, then you assign the people to teams 0, 1, 2, 3, 0, 1, 2, 3, etc. like this: [['paul', 'steve', 'nick', 'michelle'], ['francois', 'arnold', 'anna', 'jeremy'], ['andrew', 'tom', 'dan', 'karen'], ['sue', 'danny', 'diane']] Write the code for the following function. Do not assume that the list of people will divide evenly into the desired number of teams. If the list of people does not divide evenly into the desired number of teams, the teams will simply have unequal sizes. Do not assume that the number of people is at least as large as the number of teams. If there aren't enough people to cover the teams, some (or even all) teams will simply be empty. Hint: The range function will be very helpful. def form_teams (people: list[str], num_teams: int) ->\ list [list [str]]: num_teams is guaranteed to be >= 1. Return a list of lists of names from counting off. Each sublist represents a team. # Your code here
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning