@extends('template')
@section('title')
Lab 3, Part 3: Turtles like bagels
@stop
@section('content')
## Note on Labelling
The sub-tasks in this section are marked
Partner A or
Partner B to indicate how to work on them,
as in [an earlier task of this lab](happy-owls).
# Lab 3, Part 3: 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 `lab03/bagel.py` to get started...
## Function 1: `makeOneBagel`
## A plate of bagels
Now, add two more bagels to your drawing. It doesn't matter exactly
where they go, just make sure they are not overlapping each other.
You can add the lines below to your `test` function:
```py
teleport(---, ---)
# replace the DESCRIPTIONS_BELOW with your own values
makeOneBagel(BAGEL_SIZE, OUTERCOLOR, INNERCOLOR)
# move your turtle to a new location for the second bagel
teleport(---, ---)
makeOneBagel(BAGEL_SIZE, OUTERCOLOR, INNERCOLOR)
# move your turtle to a new location for the third bagel
teleport(---, ---)
makeOneBagel(BAGEL_SIZE, OUTERCOLOR, INNERCOLOR)
```
## Hungry, huh? Someone took a bite out of each bagel!
Hints:
1. The bite should be added only once to your code -- where?
2. The bite is proportional to the bagel size
## Function 2: `makeRandomBagel`
Here are two built-in python functions that you will use in this task:
* `random.randint`: returns a random integer between `a` and `b`, inclusive. For example,
```py
random.randint(1,6) # returns a random integer between 1-6, inclusive
random.randint(50,100) # returns a random integer between 50-100, inclusive
```
* `random.choice`: returns a randomly chosen item from the given list
```py
random.choice(['red','orange','yellow','blue']) # returns a random color
random.choice(['Jimin','RM','Jungkook','Jin','V','Suga','J-Hope']) # returns a random name
random.choice([4.3, 5.9, 3.14, 2.01]) # returns a random number
```
Note the square brackets `[ ]` tucked inside the parentheses of `random.choice`. This is a symbol that python recognizes as grouping the set of items together.
**Important Note**: You must add another import statement to the top of your file:
```py
import random
```
in order for the random functions to work correctly.
The `makeRandomBagel` function accepts one parameter, `backgroundColor`,
and will draw a bagel using the turtle.
The bagel hole should be half the radius. Your function will use
`random.randint` to select a size in the range between 20 and 200,
and `random.choice` to select a color from a set of four colors that
you select from [this colors list](/labs/lab01/colors).
You can add this snippet of code to your `test` function.
```py
teleport(0,100)
makeRandomBagel('white')
teleport(150, 300)
makeRandomBagel('white')
teleport(-100,-150)
makeRandomBagel('white')
```
Executing that snippet 3 different times generates 3 different images:
## [OPTIONAL] Function 3: Add some random seeds to your [everything] bagel*
*Hat tip to Maxine Aguilar and Taylor Balfour for this idea
Hints:
1. Write one function to return one randomly placed seed
0. Here's a function you can use: `random.randint`. For example, `random.randint(1, 10)` returns a randomly selected integer between
1 and 10, inclusive.
2. The images above show 5 seeds added to each bagel (where
in your code should you add the seeds to your bagel?)
3. Ideally, seeds should only appear on the body of the bagel, but
its ok if yours appear in the "hole"
4. Later in the semester, we will learn a better way of adding a
whole bunch of seeds (repeating a block of code)
@include('/labs/lab03/_toc')
@stop