Learn
Functions
type()

Finally, the type() function returns the type of the data it receives as an argument. If you ask Python to do the following:

print type(42) print type(4.2) print type('spam')

Python will output:

<type 'int'> <type 'float'> <type 'str'>

Instructions

1.

Have Python print out the type of an int, a float, and a str string in the editor. You can pick any values on which to call type(), so long as they produce one of each.

Folder Icon

Take this course for free

Already have an account?