More Nested Loops and Lab 5

Slides:



Advertisements
Similar presentations
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
Advertisements

Lab 07: Caesar Cypher Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Lab 07: Caesar Cypher Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Intro to Nested Looping Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Intro to Nested Looping Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Introduction to Strings Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg 1.
Computer Science: A Structured Programming Approach Using C1 6-6 Loop Examples This section contains several short examples of loop applications. Each.
Thinking about programming Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Problem Solving Intro to Computer Science CS1510 Dr. Sarah Diesburg 1.
Thinking about programming
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Thinking about programming
Topics discussed in this section:
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
CS150 Introduction to Computer Science 1
Topics discussed in this section:
Chapter 8 Namespaces and Memory Realities
Thinking about programming
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Introduction to Strings
Introduction to Strings
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Lists – Indexing and Sorting
Intro to Nested Looping
String Encodings and Penny Math
More Functional Decomposition
Intro to Nested Looping
Topics discussed in this section:
Types, Truth, and Expressions (Part 2)
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Chapter 8 Namespaces and Memory Realities
Thinking about Strings
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Topics discussed in this section:
More on Functions (Part 2)
Lists – Indexing and Sorting
Intro to Nested Looping
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Introduction to Strings
More Repetition While and For loop variations
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Thinking about programming
Chapter 8 Namespaces and Memory Realities
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Thinking about programming
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg
Introduction to Strings
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Nested Looping
Print the following triangle, using nested loops
More Functional Decomposition
Lists – Indexing and Sorting
String Encodings and Penny Math
Types, Truth, and Expressions
Course Information and Introductions
Introduction to Strings
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Solving equations by factoring
More Functional Decomposition
Presentation transcript:

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

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?

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)

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

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

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

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

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