Basic Python 9: Python Type Conversion and Type Casting
Python Type Conversion and Type Casting:
----------------------------------------
Type Conversion:
----------------
The process of converting the value of one data type (integer, string, float, etc.) to another data type is called type conversion.
1. Implicit Type Conversion
2. Explicit Type Conversion
Implicit Type Conversion:
Python automatically converts one data type to another data type. This process doesn't need any user involvement.
ex:
num_int = 123
num_flo = 1.23
num_new = num_int + num_flo
print("datatype of num_int:",type(num_int))
print("datatype of num_flo:",type(num_flo))
print("Value of num_new:",num_new)
print("datatype of num_new:",type(num_new))
output:
- We add two variables num_int and num_flo, storing the value in num_new.
- We will look at the data type of all three objects respectively.
- In the output, we can see the data type of num_int is an integer while the data type of num_flo is a float.
Also, we can see the num_new has a float data type because Python always converts smaller data types to larger data types to avoid the loss of data.
ex2:
num_int = 123
num_str = "456"
print("Data type of num_int:",type(num_int))
print("Data type of num_str:",type(num_str))
print(num_int+num_str)
we will get error we need to do Explicit Type Conversion
Explicit Type Conversion:
-------------------------
Users convert the data type of an object to required data type. We use the predefined functions like int(), float(), str(), etc to perform explicit type conversion.
ex:
num_int = 123
num_str = "456"
print("Data type of num_int:",type(num_int))
print("Data type of num_str before Type Casting:",type(num_str))
num_str = int(num_str)
print("Data type of num_str after Type Casting:",type(num_str))
num_sum = num_int + num_str
print("Sum of num_int and num_str:",num_sum)
print("Data type of the sum:",type(num_sum))
___________________ API Automation __________________
➡️ Rest Assured Using Java → https://youtube.com/playlist?list=PLQKDzuA2cCjrxlZkE8e_NOeQFJQXRHp0n
➡️ Karate Framework using Maven → https://youtube.com/playlist?list=PLQKDzuA2cCjoWKMw8bpnOlr70PNSVdkf6
______________ Programing Language _____________________
➡️ Basic Python → https://youtube.com/playlist?list=PLQKDzuA2cCjp-gnUFFPvXcMllAlfVPph5
➡️ Core Java → https://youtube.com/playlist?list=PLQKDzuA2cCjod85qsWBGR-25onbE1GH_i
____________ Performances Testing ____________________
➡️ JMeter Beginner → https://youtube.com/playlist?list=PLQKDzuA2cCjrukNp3JNCTnKi89C9CiFz8
➡️ Locust Beginner → https://youtube.com/playlist?list=PLQKDzuA2cCjptRRRUWyLZoaeVuoctG35L
____________ Git and GitHub ______________________________
➡️ Git and GitHub Beginner → https://youtube.com/playlist?list=PLQKDzuA2cCjrsvfgzsVajJVqj7rck7X2q
______________Manual Testing _____________________
➡️ Manual Testing → https://youtube.com/playlist?list=PLQKDzuA2cCjovVbXzK8QiVeZamz-lLW0-
_______________Automation Testing ___________________
➡️ Selenium Cucumber Framework using Java → https://youtube.com/playlist?list=PLQKDzuA2cCjpsMVO0Cj_JIDURpJSzVcmn
➡️ Robot Framework with Python → https://youtube.com/playlist?list=PLQKDzuA2cCjrVs8t8_b4LTguHA1XGTZI_
➡️ Beginner Karate Framework using Intellij → https://youtube.com/playlist?list=PLQKDzuA2cCjqUiNSoEtGJSAuDYvleZcpQ
➡️ Karate Framework with Gradle using eclipse → https://youtube.com/playlist?list=PLQKDzuA2cCjo_VayskAv-1qnUg1b2mjWi
➡️ Basic Selenium WebDriver using Java → https://youtube.com/playlist?list=PLQKDzuA2cCjpEL8xZFg6I1TOcerxKh0nX
➡️ TestNG Framework → https://youtube.com/playlist?list=PLQKDzuA2cCjoKVdgCDCuCnUMFv-9jZ2cr
➡️ Robot Framework with RIDE → https://youtube.com/playlist?list=PLQKDzuA2cCjqmT4GambzrUjtLfEkXmMzw
_________________ Beginner Jenkins _____________________
➡️ Beginner Jenkins → https://youtube.com/playlist?list=PLQKDzuA2cCjrwNyMgYffggbTMoNrtwpGk
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Basic Python 9: Python Type Conversion and Type Casting», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.