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

Kursinnehåll

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
Uppgift

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.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 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
Uppgift

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.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 3
Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Vi beklagar att något gick fel. Vad hände?
some-alt