Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть Python For Beginners in 3 Minutes | Variable Types and Value Assignments Part 3

  • The Rooftop Gardener
  • 2021-05-22
  • 1730
Python For Beginners in 3 Minutes | Variable Types and Value Assignments Part 3
pythonpython programminglearn python programminglearn python in under 3 minutespython solutionsunder 3 minutesbeginning programmingcodingbeginnersthe rooftop gardenervariabledescriptive namesvariables are containersmulti-word variable namespython variablestypesclassmultivaluemultivariablevalue assignmentsunpacking list to variablesunpackingvariable value assignmentssingle value multivariable
  • ok logo

Скачать Python For Beginners in 3 Minutes | Variable Types and Value Assignments Part 3 бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно Python For Beginners in 3 Minutes | Variable Types and Value Assignments Part 3 или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

  • Информация по загрузке:

Cкачать музыку Python For Beginners in 3 Minutes | Variable Types and Value Assignments Part 3 бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео Python For Beginners in 3 Minutes | Variable Types and Value Assignments Part 3

Variable Types and Assignments

Unlike some programming languages, Python does not require a variable to be declared with any particular data type first before it can hold a value.

In Python, a variable is created as soon as a value is assigned to it. The value assigned to the variable determines the data type.

counter = 0

At this point, a variable is created with a name "counter" clearly is an "integer" having an initial value of zero, if this the first time this variable is used.

Interestingly, Python allows any existing variable to change its type when you assign a new value to it. For example:

counter = 0
print(counter)
print(type(counter))

counter = "Hello"
print(counter)
print(type(counter))

The variable

counter

was initially of type or class "int" or integer when it was assigned a value of 0.

The next assignment of value to the counter changes its type into a type or class "str" or string.

Further down our code we can also assign to the same variable the type or class "float" or numbers with decimal places.

counter = 9.39
print(counter)
print(type(counter))

Let's try another type or class of data that can be stored in a variable. It is called "boolean" and can store either True or False values. Using the same variable:

counter = True
print(counter)
print(type(counter))

*Assigning one value to multiple variables.
If you want to store one value to different variables, the following Python code can do it without any issue:

fruit1 = fruit2 = fruit3 = "Strawberry"

*Assigning multiple values to multiple variables.

One of the cool things I have learned in Python is the different ways it assigns values to variables. We have seen so far that we use the "equal" sign to assign one value to one variable. Say we have the following assignments:

fruit1 = "Mango"
fruit2 = "Apple"
fruit3 = "Cherry"
print(fruit1)
print(fruit2)
print(fruit3)

The preceding code may be written as follows:

fruit1, fruit2, fruit3 = "Mango", "Apple", "Cherry"
print(fruit1)
print(fruit2)
print(fruit3)

This way we are assigning values to multiple variables in just one line of code instead of three.

*Assigning one value to multiple variables.
If you want to store one value to different variables, the following Python code can do it without any issue:

fruit1 = fruit2 = fruit3 = "Strawberry"
print(fruit1)
print(fruit2)
print(fruit3)

*Another way to store data to variables is to "unpack" a collection like a list or a set. The following code stores the values from the list into the respective variables.

fruits = ["Mango", "Apple", "Cherry"]
fruit1, fruit2, fruit3 = fruits
print(fruit1)
print(fruit2)
print(fruit3)

If you like the video, please don't forget to subscribe, like, and share.

Music Credit: See You On The Otherside - The 126ers
   / @hutchinw  

#python​ #beginners #variable #datatypes #class #unpacking #multivalue #multivariable

Комментарии

Информация по комментариям в разработке

Похожие видео

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]