Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
The First while Loop | The while Loop
Python Loops Tutorial
course content

Conteúdo do Curso

Python Loops Tutorial

Python Loops Tutorial

1. The for Loop
2. The while Loop
3. Nested Loops

The First while Loop

Let's proceed!

The while loop!

The while statement verifies a condition. The condition should yield a Boolean value, which can be either True or False.

If the condition evaluates to True, the while statement executes the statements contained within its block.

The while statement keeps reevaluating the condition with each iteration and continues to execute its block until the condition becomes False.

Take a look at the code below:

1234567
# Setting variable to change numbers i = 0 # Printing numbers from 0 to 9 while i < 10: print(i) i += 1
copy

How does the code work?

Tarefa

Print numbers from 10 to 0.

  1. Initialize the while loop with the variable i.
  2. Continuously print the numbers while the loop is active.
  3. Decrease i by 1 with each iteration.

Tarefa

Print numbers from 10 to 0.

  1. Initialize the while loop with the variable i.
  2. Continuously print the numbers while the loop is active.
  3. Decrease i by 1 with each iteration.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 2. Capítulo 1
toggle bottom row

The First while Loop

Let's proceed!

The while loop!

The while statement verifies a condition. The condition should yield a Boolean value, which can be either True or False.

If the condition evaluates to True, the while statement executes the statements contained within its block.

The while statement keeps reevaluating the condition with each iteration and continues to execute its block until the condition becomes False.

Take a look at the code below:

1234567
# Setting variable to change numbers i = 0 # Printing numbers from 0 to 9 while i < 10: print(i) i += 1
copy

How does the code work?

Tarefa

Print numbers from 10 to 0.

  1. Initialize the while loop with the variable i.
  2. Continuously print the numbers while the loop is active.
  3. Decrease i by 1 with each iteration.

Tarefa

Print numbers from 10 to 0.

  1. Initialize the while loop with the variable i.
  2. Continuously print the numbers while the loop is active.
  3. Decrease i by 1 with each iteration.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 2. Capítulo 1
toggle bottom row

The First while Loop

Let's proceed!

The while loop!

The while statement verifies a condition. The condition should yield a Boolean value, which can be either True or False.

If the condition evaluates to True, the while statement executes the statements contained within its block.

The while statement keeps reevaluating the condition with each iteration and continues to execute its block until the condition becomes False.

Take a look at the code below:

1234567
# Setting variable to change numbers i = 0 # Printing numbers from 0 to 9 while i < 10: print(i) i += 1
copy

How does the code work?

Tarefa

Print numbers from 10 to 0.

  1. Initialize the while loop with the variable i.
  2. Continuously print the numbers while the loop is active.
  3. Decrease i by 1 with each iteration.

Tarefa

Print numbers from 10 to 0.

  1. Initialize the while loop with the variable i.
  2. Continuously print the numbers while the loop is active.
  3. Decrease i by 1 with each iteration.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Let's proceed!

The while loop!

The while statement verifies a condition. The condition should yield a Boolean value, which can be either True or False.

If the condition evaluates to True, the while statement executes the statements contained within its block.

The while statement keeps reevaluating the condition with each iteration and continues to execute its block until the condition becomes False.

Take a look at the code below:

1234567
# Setting variable to change numbers i = 0 # Printing numbers from 0 to 9 while i < 10: print(i) i += 1
copy

How does the code work?

Tarefa

Print numbers from 10 to 0.

  1. Initialize the while loop with the variable i.
  2. Continuously print the numbers while the loop is active.
  3. Decrease i by 1 with each iteration.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 2. Capítulo 1
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt