From the course: Python Functions for Data Science

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Python type() function

Python type() function - Python Tutorial

From the course: Python Functions for Data Science

Start my 1-month free trial

Python type() function

- [Instructor] Another fundamental built-in function that comes in handy when working with data in Python is type. The function type takes in an object as input and returns the data type of a given object. To show you how the function type is used, I'll be working through some examples. Let's say I have a variable named listF. To find the type of this variable, I can call the function type and pass in listF, it will look like this. There, listF has the type list. Next, say that I have a variable named nums. To find the type of this variable, I can call the function type and pass in nums, it will look like this. I run the cell now, there we go. Nums has the type tuple, then I have a variable named names. To find the type of this variable, I can call the function type and pass in names, It will look like this. Now I run the cell. As you can see, names has the type set. Next up, I have a variable named exercise. To…

Contents