Handle More Challenging Math in Python
Python provides several additional math operations.
1234567891011# Default division print(18 / 4) # Floor division print(18 // 4) # Remainder of the division print(18 % 4) # Raising to the power of 4 print(18 ** 4)
Why Are These Operations Helpful?
Imagine you have $50 and want to buy as many cookie packs as possible, with each pack costing $6. To determine how many packs you can buy and how much money will remain, you can use these operations:
50 // 6
gives8
, meaning you can buy 8 packs.50 % 6
results in2
, meaning you’ll have $2 left after the purchase.
Tehtävä
Swipe to start coding
- On the second line, compute the floor division of
234
by32
. - On the fifth line, determine the remainder when
356
is divided by17
.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 1. Luku 4
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Awesome!
Completion rate improved to 1.64
Handle More Challenging Math in Python
Pyyhkäise näyttääksesi valikon
Python provides several additional math operations.
1234567891011# Default division print(18 / 4) # Floor division print(18 // 4) # Remainder of the division print(18 % 4) # Raising to the power of 4 print(18 ** 4)
Why Are These Operations Helpful?
Imagine you have $50 and want to buy as many cookie packs as possible, with each pack costing $6. To determine how many packs you can buy and how much money will remain, you can use these operations:
50 // 6
gives8
, meaning you can buy 8 packs.50 % 6
results in2
, meaning you’ll have $2 left after the purchase.
Tehtävä
Swipe to start coding
- On the second line, compute the floor division of
234
by32
. - On the fifth line, determine the remainder when
356
is divided by17
.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Awesome!
Completion rate improved to 1.64Osio 1. Luku 4
single