How to Convert Float to Int in Python?

Last updated on February 24, 2023

Float value can be converted into an integer by using Python’s built-in function int(). It converts the first argument’s data type into an integer.




  • It has one required parameter that refers to the value which needs to convert into an integer.


Let’s create a variable and assign a float value to it.

bookPrice = 3.50
// Output: 3.5

If you want to check the data type of bookPrice variable then you can use the type() function that returns the type of a variable. To do that pass the bookPrice variable into the type() function.

// Output: <class 'float'>

The type() function returns the float data type of bookPrice variable. Now it is confirmed that bookPrice variable’s data type is float. To convert it into an integer, use python’s built-in function int() and assign it to any variable. Below is an example,

convertIntoInteger = int(bookPrice)
// Output: 3

Here, the int() function converts bookPrice value into an integer as you can see its output has changed to 3. To check further its data type, pass it as an argument in the type() function. Below is the example

// Output: <class 'int'>


This article explains float value conversion, and for that, this article has used the int() function. The int() function takes a string or number value in an argument and converts it into an integer.

Written by
I am a skilled full-stack developer with extensive experience in creating and deploying large and small-scale applications. My expertise spans front-end and back-end technologies, along with database management and server-side programming.

Share on:

Related Posts

Tags: Float, Integer, Python,