Assignment 2 Question 3 Hint
Due Tues, Sep 18
Instead of solving problem 3 all at once, begin with an easier problem and gradually add complexity. First, write a loop that simply counts up to an integer, as shown below. You should be able to use some of our class code to accomplish this.
Enter a size: 5
1
2
3
4
5
Next, try to print the spaces on the left side of the number tree. You will have to write an expression for the correct number of spaces in each line. It may be better to print an X instead of a space at this stage so that you can see what you're doing:
Enter a size: 5
XXXX
XXX
XX
X
Remember that you can use a statement like print("X", end="") to print without going to the next line. At this point, you will want to add an inner loop to print the numbers from 1 up to the line number, as shown below:
Enter a size: 5
XXXX1
XXX12
XX123
X1234
12345
Continue to add more loops as necessary, and finally replace the X's with spaces.