Presentation is loading. Please wait.

Presentation is loading. Please wait.

More Nested Loops and Lab 5

Similar presentations


Presentation on theme: "More Nested Loops and Lab 5"— Presentation transcript:

1 More Nested Loops and Lab 5
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg

2 Yesterday’s Lab Activity A
New ways to print on the same line What gave you the most trouble in Activity B? How did you address this? What gave you the most trouble in Activity C?

3 New ways to print # Playing with print endings x = 0 while x<10:
print(x, end=‘ ’) x=x+1 print() print(“Final value of x is”,x)

4 What code could we write to print a triangle?
* * * * * * * * * * * * * * *

5 What code could we write to print a triangle?
First we need to figure out how to print one line of stars of varied length Next, we need to do this over and over

6 Important things Name your variables descriptive names!
x, y, z, a, b, c don’t make much sense with nested loops Once you figure out what you need to do, write a detailed comment about it Start by solving a small problem, then work up to larger problems If all else fails, step through the program line by line

7 What about a right-justified triangle?
* * * * * * * * * * * * * * *

8 What about a right-justified triangle?
We need to print spaces before the stars To solve the problem, we need to think about 2 things Number of spaces Number of stars


Download ppt "More Nested Loops and Lab 5"

Similar presentations


Ads by Google