Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Handle More Complex Math in Python | First Acquaintance with Python
Introduction to Python
course content

Kursusindhold

Introduction to Python

Introduction to Python

1. First Acquaintance with Python
2. Variables and Types in Python
3. Conditional Statements in Python
4. Other Data Types in Python
5. Loops in Python
6. Functions in Python

book
Handle More Complex 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)
copy

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 gives 8, meaning you can buy 8 packs.
  • 50 % 6 results in 2, meaning you’ll have $2 left after the purchase.
Opgave

Swipe to start coding

  1. On the second line, compute the floor division of 234 by 32.
  2. On the fifth line, determine the remainder when 356 is divided by 17.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 4
toggle bottom row

book
Handle More Complex 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)
copy

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 gives 8, meaning you can buy 8 packs.
  • 50 % 6 results in 2, meaning you’ll have $2 left after the purchase.
Opgave

Swipe to start coding

  1. On the second line, compute the floor division of 234 by 32.
  2. On the fifth line, determine the remainder when 356 is divided by 17.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 4
Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Vi beklager, at noget gik galt. Hvad skete der?
some-alt