Lesson 4
for-loop continued
Pseudo code
# We need to work out spacing vs asterisk
# We need to iterate at least 5 times
# Let's use variable s for spacing, variable a for asterisk
# iteration 1: a = 5, s = 0
# iteration 2: a = 4, s = 1
# iteration 3: a = 3, s = 2
# iteration 4: a = 2, s = 3
# iteration 5: a = 1, s = 4
The following line of the code from above shows code that has been commented out. That means it doesn't get executed when you click on run.
- We can use comment to write pseudo code to outline our logic OR disable the code.
for-loop continued 2
Pseudo code
# We need to work out spacing vs asterisk
# We need to iterate at least 5 times
# Let's use variable s for spacing, variable a for asterisk
# iteration 1: a = 0, s = 6
# iteration 1: a = 1, s = 5
# iteration 2: a = 2, s = 4
# iteration 3: a = 3, s = 3
# iteration 4: a = 4, s = 2
# iteration 5: a = 5, s = 1
Coding challenge for next week
Tweak the code from above to print a bazaar looking shape. I don't care what it looks like. Create something.