Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
For Loop | Introduction to Python 2/2
Introduction to Python for Data Analysis
course content

Contenido del Curso

Introduction to Python for Data Analysis

Introduction to Python for Data Analysis

1. Introduction to Python 1/2
2. Introduction to Python 2/2
3. Explore Dataset
4. Becoming an Analyst

bookFor Loop

We use loops if we want to repeat any action n-times.

Look at the example!

12345
# Decreasing prices by 1 prices = [3, 5, 6, 2, 7, 8] for i in prices: print(i, end = ' ')
copy

end = ' ' means that the result will be written in one row (not column).

Look at the table to understand how to minimize the writing of mathematical operators!

FormulaHow to minimize
a = a + 1a += 1
a = a - 1a -= 1
a = a * 2a *= 2
a = a / 2a /= 2

Tarea

Update subscription prices according to discounts.

  1. Set the for loop to work with the prices using the i iterator.
  2. Set the condition if the element of the list is greater than 30.
  3. Set the 25% discount if the price is greater than 30.
  4. Decrease the i by 3.
  5. Print the prices.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 5
toggle bottom row

bookFor Loop

We use loops if we want to repeat any action n-times.

Look at the example!

12345
# Decreasing prices by 1 prices = [3, 5, 6, 2, 7, 8] for i in prices: print(i, end = ' ')
copy

end = ' ' means that the result will be written in one row (not column).

Look at the table to understand how to minimize the writing of mathematical operators!

FormulaHow to minimize
a = a + 1a += 1
a = a - 1a -= 1
a = a * 2a *= 2
a = a / 2a /= 2

Tarea

Update subscription prices according to discounts.

  1. Set the for loop to work with the prices using the i iterator.
  2. Set the condition if the element of the list is greater than 30.
  3. Set the 25% discount if the price is greater than 30.
  4. Decrease the i by 3.
  5. Print the prices.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 5
toggle bottom row

bookFor Loop

We use loops if we want to repeat any action n-times.

Look at the example!

12345
# Decreasing prices by 1 prices = [3, 5, 6, 2, 7, 8] for i in prices: print(i, end = ' ')
copy

end = ' ' means that the result will be written in one row (not column).

Look at the table to understand how to minimize the writing of mathematical operators!

FormulaHow to minimize
a = a + 1a += 1
a = a - 1a -= 1
a = a * 2a *= 2
a = a / 2a /= 2

Tarea

Update subscription prices according to discounts.

  1. Set the for loop to work with the prices using the i iterator.
  2. Set the condition if the element of the list is greater than 30.
  3. Set the 25% discount if the price is greater than 30.
  4. Decrease the i by 3.
  5. Print the prices.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

We use loops if we want to repeat any action n-times.

Look at the example!

12345
# Decreasing prices by 1 prices = [3, 5, 6, 2, 7, 8] for i in prices: print(i, end = ' ')
copy

end = ' ' means that the result will be written in one row (not column).

Look at the table to understand how to minimize the writing of mathematical operators!

FormulaHow to minimize
a = a + 1a += 1
a = a - 1a -= 1
a = a * 2a *= 2
a = a / 2a /= 2

Tarea

Update subscription prices according to discounts.

  1. Set the for loop to work with the prices using the i iterator.
  2. Set the condition if the element of the list is greater than 30.
  3. Set the 25% discount if the price is greater than 30.
  4. Decrease the i by 3.
  5. Print the prices.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 2. Capítulo 5
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
some-alt