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

Veröffentlicht am: 22 Dezember 2022
auf dem Kanal: 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.


Auf dieser Seite können Sie das Online-Video Static Typing Vs Dynamic Typing in Python / type casting in python mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer 99FinTech 22 Dezember 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 22 Mal angesehen und es wurde von 0 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!