Search Header Logo
CMU CS Regular Poygons and Stars

CMU CS Regular Poygons and Stars

Assessment

Presentation

Computers

9th - 12th Grade

Practice Problem

Easy

Created by

Maria Cruz Farooqi

Used 2+ times

FREE Resource

7 Slides • 3 Questions

1

CMU CS 1.3.3 Regular Polygons and Stars

2

​Regular Polygons

We know how to draw a square -- we use Rect and make the width and height the same. But what about a triangle? Or a pentagon (with 5 sides) or a hexagon (with 6 sides), and so on? These are called regular polygons, and we draw these using

RegularPolygon.

3

​We draw a regular polygon similarly to a circle -

- with an (x,y) center and a radius.

We just need one more argument: the number of points (or sides, if you prefer, since there are the same number of points as sides). Here is how we draw a hexagon centered at (200, 100) with a radius of 75:

​RegularPolygon( 200, 100, 75, 6 )

media

4

media

​We can see that this fits just inside a circle:

​Circle(200, 100, 75, fill='cyan') RegularPolygon(200, 100, 75, 6)

5

Multiple Choice

Question image

What happens if you run the previous code with 100 sides?

1

It looks like a square.

2

It looks like a line.

3

It looks like a circle.

4

It crashes (you cannot draw a 100-sided regular polygon).

6

media

​Circle(200, 100, 75, fill='cyan')

RegularPolygon(200, 100, 75, 100)

7

​Stars

We draw a star in the same way that we draw a RegularPolygon:

​Star(200, 100, 75, 5)

media

​We can see that this, too, fits just inside a circle:

​Circle(200, 100, 75, fill='cyan')

Star(200, 100, 75, 5)

media

8

media

​Roundness

You probably have a clear idea what a 5-sided star should look like -- basically, like it does on any flag. Same goes for a 6-sided star. But a 7-sided star is less obvious.

Which of the following is the right shape for a 7-sided star? 7-sided stars of different roundnesses. We see that there are many different kinds of 7-sided stars, some are more circular or rounder than others. The same is true for all stars. When we create a star, we can set its roundness to any value between 0 and 100. For example:

​Star( 80, 130, 35, 7, roundness=20) Star(160, 130, 35, 7, roundness=40) Star(240, 130, 35, 7, roundness=60) Star(320, 130, 35, 7, roundness=80)

9

Dropdown

Question image
Complete the code for the center diamond.

Star (​
,​
,​
,​
, fill='crimson', roundness=​
)

10

Dropdown

Question image
Complete the code for the diamond beneath the number 2.

Star (​ ​
,​ ​
,​ ​
,​
, fill='crimson', roundness=​
)

CMU CS 1.3.3 Regular Polygons and Stars

Show answer

Auto Play

Slide 1 / 10

SLIDE