logo CodeStepByStep logo

loop_table2_constant

Language/Type: Python basics for loops loop table

Suppose that you have a variable called line that will take on the values 1, 2, 3, 4, and so on, and a constant named SIZE that takes one of two values. You are going to formulate expressions in terms of line and SIZE that will yield different sequences of numbers of characters. Fill in the table below, indicating an expression that will generate each sequence.

Problem # line SIZE # of chars
a. 1, 2, 3, 4, 5, 6, ... 1 4, 6, 8, 10, 12, 14, ...
1, 2, 3, 4, 5, 6, ... 2 6, 8, 10, 12, 14, 16, ...
b. 1, 2, 3, 4, 5, 6, ... 3 13, 17, 21, 25, 29, 33, ...
1, 2, 3, 4, 5, 6, ... 5 19, 23, 27, 31, 35, 39, ...
c. 1, 2, 3, 4, 5, 6, ... 4 10, 9, 8, 7, 6, 5, ...
1, 2, 3, 4, 5, 6, ... 9 20, 19, 18, 17, 16, 15, ...

Formulate your answer in the form A * line + B * SIZE + C as appropriate.

a.
b.
c.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.