logo CodeStepByStep logo

slash_figure2_loop_table

Language/Type: Python basics for loops loop table

Suppose that a program has been written that produces the output shown in the previous problem, slash_figure_loop_table. Now the author wants the program to be scalable using a constant called SIZE. The previous output used a constant height of 6, since there were 6 lines. The output for size 6 was:

!!!!!!!!!!!!!!!!!!!!!!
\\!!!!!!!!!!!!!!!!!!//
\\\\!!!!!!!!!!!!!!////
\\\\\\!!!!!!!!!!//////
\\\\\\\\!!!!!!////////
\\\\\\\\\\!!//////////

And the original table for size 6 was:

Line \ ! /
1 0 22 0
2 2 18 2
3 4 14 4
4 6 10 6
5 8 6 8
6 10 2 10

The following is the output for a constant height of 4.

!!!!!!!!!!!!!!
\\!!!!!!!!!!//
\\\\!!!!!!////
\\\\\\!!//////

Use the new output and new table that shows the expressions for the character counts at this new size of 4, and compare these tables to figure out the expressions for any size using the SIZE constant.

Line \ ! /
1 0 14 0
2 2 10 2
3 4 6 4
4 6 2 6

Write your answers in the form A * line + B * SIZE + C as appropriate; omit any terms with zero values.

expression for \ and /
expression for !

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve an exercise or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect tests, etc.), please

Is there a problem? Contact a site administrator.

©, all rights reserved.