AI engineering glossary · Python core
What is type conversion?
Type conversion (also called casting, type casting): Changing a value from one type to another by calling the target type as a function, such as int(), float(), str() or list(). Conversion is often needed because input() returns text and arithmetic needs numbers. Invalid input raises a ValueError.
Type conversion: an example
int('42') gives 42, float('3.5') gives 3.5, and int('abc') raises ValueError. list('hi') gives ['h', 'i'].
Related terms
More Python core terms
Where you learn it
Type conversion is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.