@extends('template')
@section('title')
Lab 2: Turtles like bagels
@stop
@section('content')
# Lab 2: Turtles like bagels
Our goal in this part of today's lab is to create scenes of yummy bagels like the following:
Observations
+ What are the common characteristics of a bagel?
+ What are the characteristics that differ for each bagel? (These will be your parameters!)
To accomplish this task, we'll create a function that will draw a bagel and we'll call it `makeOneBagel`.
**Open the provided file** `lab02/bagels.py` to get started...
## Function 1: `makeOneBagel`
Partner A
`makeOneBagel` accepts the following parameters:
1. `size` - The radius of the bagel circle
1. `color` - What color the bagel should be
This function will draw a bagel using the turtle by setting a thick pen
size and drawing a circle using `drawCircle`. The circle radius should be
the given size, and the pen thickness should be 1/2 of that size.
To start with, create a definition for `makeOneBagel` in your `bagels.py`
file, and then **write the docstring** for this function that describes
what it will do. After you've explained our plan, you are ready to write
the code.
Write your code for `makeOneBagel`, and then test your work by **first
running the file** (which defines your function) and then **pasting this
code into the shell**:
```py
makeOneBagel(60, 'tomato3')
```
When you hit enter, you should see a bagel like this:
Friendly reminder: you can see all [available turtle colors
here](/reference/colors)
## A plate of bagels
Now, **open the provided file** `test_bagels.py`. This is a testing file
that will import your `bagels` file and test the functions in it. It
comes with code for drawing four bagels, and if you run it, you should
see this:
## Hungry, huh? Someone took a bite out of the bagel!
Partner B
Define a new function called `makeBittenBagel` which draws a bagel, but
then takes a bite out of it. This function will need one extra parameter
to tell it what the background color is.
Here's what the bitten bagel looks like:
Hints:
1. You can use `makeOneBagel` from within `makeBittenBagel` to do a lot
of the work.
2. To "erase" part of the bagel, just draw a filled circle on top that's
the same color as the background.
3. The bite is proportional to the bagel size: it always bites halfway
through the bagel.
There is a line of code in `test_bagels.py` which is commented out with a
`#` that calls `makeBittenBagel`. Uncomment that line, and comment out
the call to `makeOneBagel` above it so that you can replace one of your
four test bagels with a bitten bagel.
## That's it!
Congratulations, you made it to the end of the lab!
If you still have time left, there are some optional exercises you could
work on:
- [The Motifs exercises](motifs) will show you how to use functions with
`wavesynth` audio.
- If you prefer, there are [extra bagels exercises](extra_bagels) that
will build on the code you just wrote.
@include('/labs/lab02/_toc')
@stop