Contenido del Curso
Introduction to Python
3. Conditional Statements
Introduction to Python
¿Este curso te parece demasiado fácil?
Sumérgete en la práctica del mundo real con nuestro curso centrado en la aplicación
Nice work! Python provides several additional math operations, including:
//
- floor division or integer division;%
- modulus or remainder after division;**
- exponentiation or raising to a power.
It's important to note that you can't use the traditional ^
symbol for exponentiation in Python, as it yields a different result. The syntax for these operations mirrors that of basic arithmetic. For example, 18 // 4
results in 4
, because we're taking the whole number from the division (the actual result being 4.5
). 14 % 5
gives 4
, because when we divide 14
by 5
, the remainder is 4
. 4 ** 3
results in 64
, because 4
multiplied by itself three times equals 64
.
Tarea
- On the second line, compute the floor division of
234
by32
. - On the fifth line, determine the remainder when
356
is divided by17
.
Why are these operations helpful?
For instance, picture this scenario: You've got $50 and you want to buy as many cookie packs as possible, with each pack priced at $6. You're trying to figure out the max number of packs you can purchase and the change you'll receive. Using the operations above, you can solve this easily.
50 // 6
gives8
, which means you can buy 8 packs;50 % 6
results in2
, indicating you'll have $2 left after buying 8 packs.
¿Todo estuvo claro?
Contenido del Curso
Introduction to Python
3. Conditional Statements
Introduction to Python
¿Este curso te parece demasiado fácil?
Sumérgete en la práctica del mundo real con nuestro curso centrado en la aplicación
Nice work! Python provides several additional math operations, including:
//
- floor division or integer division;%
- modulus or remainder after division;**
- exponentiation or raising to a power.
It's important to note that you can't use the traditional ^
symbol for exponentiation in Python, as it yields a different result. The syntax for these operations mirrors that of basic arithmetic. For example, 18 // 4
results in 4
, because we're taking the whole number from the division (the actual result being 4.5
). 14 % 5
gives 4
, because when we divide 14
by 5
, the remainder is 4
. 4 ** 3
results in 64
, because 4
multiplied by itself three times equals 64
.
Tarea
- On the second line, compute the floor division of
234
by32
. - On the fifth line, determine the remainder when
356
is divided by17
.
Why are these operations helpful?
For instance, picture this scenario: You've got $50 and you want to buy as many cookie packs as possible, with each pack priced at $6. You're trying to figure out the max number of packs you can purchase and the change you'll receive. Using the operations above, you can solve this easily.
50 // 6
gives8
, which means you can buy 8 packs;50 % 6
results in2
, indicating you'll have $2 left after buying 8 packs.
¿Todo estuvo claro?