Static Typing Vs Dynamic Typing in Python / type casting in python

Опубликовано: 22 Декабрь 2022
на канале: 99FinTech
22
0

Static type binding, "basically, the binding process is done just once, before execution. In other hand, in languages with Dynamic type binding, the binding process is done on each assignment operation of each variable.


type casting in python is dynamic based on value assigned

In statically-typed languages the variables’ types are determined at compile-time. programmers must specify the type of each variable. Like this java code, you will have to explicitly specify it
Java Example
int i = 1;
int j;
j = 0;
On the other hand, types in Python are determined during run-time as opposed to compile-time. We do not have declare variables before using them in the code. A variable is created when it is assigned a value for the first time in the code

every time we assign variables, Python undertakes the three steps:
Number 1 - Create an object in memory that holds the value
Number 2 – create variable If the variable name does not already exist in the namespace
Number 3 - Assign the reference to the object in memory to the variable
In Python, variables do not have a type. hence, it is possible to assign objects of different type to the same variable name,
Look at this example
x = 101
x = True
x = 'Hello World'

In the first line, variable X is being assigned with the reference to the integer object with value 101 . the second line changes the reference of variable X to a different object of type Boolean while the Third line changes the reference so that X now points to a string object.


На этой странице сайта вы можете посмотреть видео онлайн Static Typing Vs Dynamic Typing in Python / type casting in python длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь 99FinTech 22 Декабрь 2022, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 22 раз и оно понравилось 0 зрителям. Приятного просмотра!