Advertisements
Advertisements
Question
Explain the difference between explicit and implicit type conversion in Python with a suitable example.
Distinguish Between
Explain
Advertisements
Solution
Implicit Conversion: Python automatically converts one data type to another.
Example:
x = 10
y = 3.5
result = x + y # x is implicitly converted to float
Explicit Conversion: The user manually converts one data type to another using functions like int(), float().
Example:
x = "10"
y = int(x) # Explicit conversion from string to integershaalaa.com
Is there an error in this question or solution?
