Section2.13Unit 2b Loops Coding Practice Exercises
90 minutes
This section contains coding practice exercises using loops. There are 3 subsections to practice with Turtle graphics, picture manipulation, and number calculations.
The code currently draws a square. Change it so that it draws a triangle. Do so by modifying the loop condition and the turn that the turtle makes without modifying other code.
Fix the indention in the code below to correctly draw 20 pentagons (5-sided polygons) in a snowflake design. The second loop should be inside the first loop.
This program should make a black-and-white image by averaging the red, green, and blue values of each pixel and then setting the red, green, and blue values to that average.
Complete the code to calculate the sum of the squares of all numbers from 1-10 (inclusive). The sum of squares is the result of squaring each value before adding it to the sum. The sum of squares for the numbers 1-4 would be \(1 * 1 + 2 * 2 + 3 * 3 + 4 * 4 = 30\text{.}\)
Below is the start of a program to calculate how long it will take to have at least $50,000 if you invest $300 per month at 0.5% interest per month (approximately 6% per year).