Skip to main content

Section 2.21 Loops Toggle Code Practice (2.7-2.12)

For each of the coding problems below, write your own solution. If you get stuck, click the Get Help button for a personalized mixed-up code problem built from your current attempt.

Activity 2.21.1.

Finish the code to print out all the values from 20 to 30 (20, 21, 22, … 30).

Activity 2.21.2.

Finish the code to print a countdown from 15 to 0 (15, 14, 13, … 0).

Activity 2.21.3.

Finish the code to print up from 0 to 50 by 5 (0, 5, 10, 15 … 50).

Activity 2.21.4.

Finish the code to print out the values from 0 to 100 by 20’s (0, 20, 40, .. 100).

Activity 2.21.5.

Finish the code to print out the values from 100 to 0 by 10’s (100, 90, 80, … 0).

Activity 2.21.6.

Finish the code to print 3 rows with 6 * in each row. Be sure to use two loops.

Activity 2.21.7.

Finish the code to print 1 (followed by a newline), then 22 (followed by a newline), and then 333 (followed by a newline). Be sure to use two loops.

Activity 2.21.8.

Finish the code to print 11111, 22222, 33333, 44444, and 55555. Be sure to use two loops.

Activity 2.21.9.

Finish the code to print 11111, 2222, 333, 44, 5. Be sure to use two loops.

Activity 2.21.10.

The even_div(s, n) method in the NumWorker class should return the number of digits in s (a string representation of a number) that are evenly divisible by n. For example, even_div("6892",3) should return 2 since both 6 and 9 are evenly divisible by 3.
You have attempted of activities on this page.