filmov
tv
Python Data Types Conversion | Explicit Type Conversion VS Implicit Type Conversion

Показать описание
Python Data Types Conversion | Explicit Type Conversion VS Implicit Type Conversion
In programming, explicit type conversion, also known as type casting, is the process of manually converting a value from one data type to another data type. This is necessary when you want to perform operations on values of different types or when you need to store a value in a variable of a different type.
Eg..
x = 3.14 # float
y = int(x) # y is now an integer 3
z = str(x) # z is now a string "3.14"
a = "42" # string
b = int(a) # b is now an integer 42
c = float(a) # c is now a float 42.0
Implicit type conversion, also known as coercion, is a process where the programming language automatically converts a value from one data type to another data type when performing an operation or assignment.
Eg...
x = 3 # int
y = x + 2.0 # y is now a float 5.0 (int is implicitly converted to float)
a = "42" # string
b = a * 2 # b is now a string "4242" (string is implicitly converted to string)
Notes:-
Python will automatically convert the operands to the "highest"
data type in the hierarchy to perform the operation.
Suggestion video:-
Comment Your query or course:-
🙏💕💕👆👆
Technologies world- jroshan
LinkedIn account:-
Instagram:
Telegram:
Facebook :
.....................................................
.....................................................
#pythontutorial #technologies #pythonprogramming #web #dataanalytics #datascience #machinelearning #artificialintelligence
In programming, explicit type conversion, also known as type casting, is the process of manually converting a value from one data type to another data type. This is necessary when you want to perform operations on values of different types or when you need to store a value in a variable of a different type.
Eg..
x = 3.14 # float
y = int(x) # y is now an integer 3
z = str(x) # z is now a string "3.14"
a = "42" # string
b = int(a) # b is now an integer 42
c = float(a) # c is now a float 42.0
Implicit type conversion, also known as coercion, is a process where the programming language automatically converts a value from one data type to another data type when performing an operation or assignment.
Eg...
x = 3 # int
y = x + 2.0 # y is now a float 5.0 (int is implicitly converted to float)
a = "42" # string
b = a * 2 # b is now a string "4242" (string is implicitly converted to string)
Notes:-
Python will automatically convert the operands to the "highest"
data type in the hierarchy to perform the operation.
Suggestion video:-
Comment Your query or course:-
🙏💕💕👆👆
Technologies world- jroshan
LinkedIn account:-
Instagram:
Telegram:
Facebook :
.....................................................
.....................................................
#pythontutorial #technologies #pythonprogramming #web #dataanalytics #datascience #machinelearning #artificialintelligence
Комментарии