Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 1.04 KB

File metadata and controls

51 lines (34 loc) · 1.04 KB

Do Now 2.06

Example 1

Write down in your notebook:

  • How would you print out something 10 times? What about 100? What about 1,000?

Open up the console, type the following code

    while True:
        print('a')

In your notebook, write responses for the following:

  1. What happens when you run this code?
  2. Try using other Boolean expressions instead of True.
  3. Using a while loop, how would you print out something 10 times? 100? 1000?

Example 2

Open up the console. Type and run the following code

    loopCounter = 0
    while loopCounter < 10:
        print('Hello World')

In your notebook, answer the following

  1. How many times will it print out?
  2. What is the output?

Example 3

In the console, add a line (#3 below) to your program:

    loopCounter = 0
    while loopCounter < 10:
        loopCounter = loopCounter + 1
        print('Hello World')

In your notebook, answer the following:

  1. How many times will it print out?
  2. What is the output?