Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele How to Work with Variables in Python | Variables and Types in Python
Introduction to Python
course content

Kurssisisältö

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
How to Work with Variables in Python

Imagine you got the cost of an item saved in the price variable and you want to apply a 15% discount. You can simply reassign the updated value like this:

1234567
# Initial price price = 50 # Applying the discount price = price * (1 - 0.15) print(price)
copy
Tehtävä

Swipe to start coding

A teacher is dividing 47 students into groups of 6.

Your task:

  • Create a variable called extra_students.
  • Find the remainder when the number of students is divided by 6.
  • Store the remainder in the variable extra_students.
  • Use the modulus operator (%) to find the remainder.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 3
toggle bottom row

book
How to Work with Variables in Python

Imagine you got the cost of an item saved in the price variable and you want to apply a 15% discount. You can simply reassign the updated value like this:

1234567
# Initial price price = 50 # Applying the discount price = price * (1 - 0.15) print(price)
copy
Tehtävä

Swipe to start coding

A teacher is dividing 47 students into groups of 6.

Your task:

  • Create a variable called extra_students.
  • Find the remainder when the number of students is divided by 6.
  • Store the remainder in the variable extra_students.
  • Use the modulus operator (%) to find the remainder.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 3
Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Pahoittelemme, että jotain meni pieleen. Mitä tapahtui?
some-alt