Course Content
Data Types in Python
Data Types in Python
How to Define a Type
We've previously come across float and integer types, so now we can tell whether a value is a float or an integer. Can you guess what the result of the math operation 6/1.5
might be? It's easy to calculate that it equals 4
, but what type does 4
belong to? It might seem like an integer, but it's actually a float. To confirm its type, you can use the type()
function.
variable = 6/1.5 print(variable) print(type(variable))
Swipe to show code editor
- Check the type of the
number1
variable. - Check the type of the
number2
variable.
Thanks for your feedback!
How to Define a Type
We've previously come across float and integer types, so now we can tell whether a value is a float or an integer. Can you guess what the result of the math operation 6/1.5
might be? It's easy to calculate that it equals 4
, but what type does 4
belong to? It might seem like an integer, but it's actually a float. To confirm its type, you can use the type()
function.
variable = 6/1.5 print(variable) print(type(variable))
Swipe to show code editor
- Check the type of the
number1
variable. - Check the type of the
number2
variable.
Thanks for your feedback!