Lesson goal: For loops to make a star

Previous: Plot a circle | Home | Next: Plot a sine wave

You can use a for-loop to plot a star pattern too, by using the for loop to count angles around a circle.

Now you try. Try fixing the r= statement and the line statement as directed.

Type your code here:


See your results here:

This code will not run. You have to fix the r=, which will be radius of the star (try 100). Then fix the line statement to draw a line from $(0,0)$ (the center of the screen), to $x$ and $y$ point computed using the two formulas. Can you do it? Dismiss.
Show a friend, family member, or teacher what you've done!

Here is a share link to your code:

Does your code work? Want to run it on your iPhone?

Here's your code:

  1. Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.

  2. Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into this page

  3. Then click the "Use on iPhone" button that you'll see.