# 11.9. Project: Collaborative Turtles Activity¶

## 11.9.1. Introduction¶

Functions and modules allow programmers to work on separate sections of code and then combine them together to create a finished project. In this activity, your class will split into teams, and each team will contain 4 groups.

Each group will create a function (or module) that performs a specific job. When all groups are ready, your team will combine all of the functions to assemble a working program.

## 11.9.2. Goal¶

If you define several turtle objects and call a `draw_polygon` function for each one, the turtles will draw their shapes sequentially (one after the other).

In this project, your team will make four turtles draw their shapes simultaneously. They will take turns drawing each side of their shapes.

Your team will also add some `random` features to make the final drawing more eye-catching.

## 11.9.3. Starter Code¶

If your teacher added you to a Trinket course, complete this project there.

If you are NOT enrolled in a Trinket course, use one of the following links to copy the starter code:

Each group needs their own copy of the code.

## 11.9.4. Activity¶

1. Each team requires 4 groups, and each group should contain 2 - 4 coders (the ideal number in each group = 3). Your teacher will split the class into the teams, and you must decide which group to join.

2. Once you join a group, decide who will be the driver, and who will be the navigators.

1. The driver types code into the editor. However, the ideas for the code MUST come from the navigators. The driver is NOT the boss. They receive directions and enter code to make the ideas work.
2. The navigators give ideas and instructions to the driver. However, they cannot type anything into the code editor themselves. The navigators are NOT the boss. They give suggestions for making the function work.

Note

Your team will only finish on time if everyone does their job.

1. Everyone needs to practice, so let everyone contribute.
2. You learn to code by coding, not watching.

1. Group 1 codes a function to randomly assign a shape to a turtle (arrow, circle, classic, square, triangle, turtle).
2. Group 2 codes a function to assign a random color to a turtle. Group members can use any colors they want, but there should be at least 7 choices in a list (Ex: red, orange, yellow, green, blue, indigo, violet).
3. Group 3 codes a function to assign a speed to a turtle. Include a default speed value just in case the function call does not include that argument.
4. Group 4 updates a function to make a list of turtles draw their shapes simultaneously instead of sequentially. The function is already in the starter code, but it does not quite work yet.

Tip

1. Each function requires a parameter for a turtle object, and each function call must include a turtle as an argument.
2. Each function might require other parameters as well. Consider the job your function must do, and decide in your group what other data will be needed.
3. For now, there is no need to include a `return` statement in any of the functions.
4. Your teacher will demonstrate a `place_turtles` function that starts different turtles at different spots on the screen.

1. `place_turtles` takes a list of turtles as one of the parameters, but it needs to be modified to make it better.
2. Your teacher will walk through how to improve the code, and your team will use the final `place_turtles` code.
5. Once each group in your team finishes their code, combine the separate functions into a single, shared file. Run the code to find and fix any bugs.

1. Decide which functions can be saved in one or more separate modules.
2. Move those functions into the modules, then import them into the main program file.
3. Add a `main()` function to the `main.py` file to hold any loose code. Also, add a function call to run `main()`.
4. As you add the module(s) and `main()`, update your program as necessary to keep it running.