Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Mutable or Immutable? | Знайомство з числами в Python
Типи даних у Python
course content

Зміст курсу

Типи даних у Python

Типи даних у Python

1. Знайомство з числами в Python
2. Істина чи брехня?
3. Рядки
4. Поєднання всіх тем разом

book
Mutable or Immutable?

Understanding the difference between mutable and immutable data types is crucial. Mutable data types can be changed after their creation, while immutable data types cannot be modified once created.

Immutable data types cannot be changed once they're created. In contrast, mutable data types can be altered after their creation.

To conclude, int and float are examples of immutable data types in Python. Reassigning a variable of these types does not alter their immutability.

1234567
# Define a variable `var1` with an initial value var1 = 40 print(var1) # output: 40 # Change the value of `var1` var1 = 50 print(var1) # output: 50
copy
Завдання

Swipe to start coding

Imagine you are managing a budget for a small project. Initially, your available budget is set to $100. However, you receive an additional funding of $50. Update the value of the project_budget variable to reflect the total available budget.

Once you've completed this task, click the button below the code to check your solution.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 2
toggle bottom row

book
Mutable or Immutable?

Understanding the difference between mutable and immutable data types is crucial. Mutable data types can be changed after their creation, while immutable data types cannot be modified once created.

Immutable data types cannot be changed once they're created. In contrast, mutable data types can be altered after their creation.

To conclude, int and float are examples of immutable data types in Python. Reassigning a variable of these types does not alter their immutability.

1234567
# Define a variable `var1` with an initial value var1 = 40 print(var1) # output: 40 # Change the value of `var1` var1 = 50 print(var1) # output: 50
copy
Завдання

Swipe to start coding

Imagine you are managing a budget for a small project. Initially, your available budget is set to $100. However, you receive an additional funding of $50. Update the value of the project_budget variable to reflect the total available budget.

Once you've completed this task, click the button below the code to check your solution.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 2
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt