## ← Making a Circle out of Squares - Programming Foundations with Python

• 2 Followers
• 23 Lines

### Get Embed Code x Embed video Use the following code to embed this video. See our usage guide for more details on embedding. Paste this in your document somewhere (closest to the closing body tag is preferable): ```<script type="text/javascript" src='https://amara.org/embedder-iframe'></script> ``` Paste this inside your HTML body, where you want to include the widget: ```<div class="amara-embed" data-url="http://www.youtube.com/watch?v=TyWOam1f8RI" data-team="udacity"></div> ``` 6 Languages

Showing Revision 4 created 05/25/2016 by Udacity Robot.

1. So, one way of doing this is to draw a square
2. and then turn a little bit to the right and then
3. draw another square. And then turn a little bit to the
4. right again and then draw another square. And keep doing that. Let's
5. build that. So, here's the piece of code that draws a
6. square. And after I've done that, what I want the turtle to
7. do is turn a little bit to the right. So, let
8. me add a piece of code that says brad.right, let's say by
9. ten degrees. Now, because I want these two statements to
10. happen over and over again, I will put them inside a loop. So let me do that. So
11. I'm going to add a for loop by saying for i in range, let's say this
12. loop runs four times. I'll add a colon and then put these two
13. things inside the loop. Let me save, and run, and see
14. what happens. Ah-ha, so here is the output. We've drawn two squares,
15. three squares and it should stop, there it is four squares. So all I have to
16. do now, is let the turtle keep going around the circle, which has 360 degrees.
17. So, this loop should run not four times, but 36
18. times instead. Let me save and
19. run that. All right. There it is, folks. A circle made out of squares. Now
20. I'm going to put some background music behind this
21. video and let you enjoy our final creation.
22. [MUSIC]
23. [MUSIC]