Integer in python | Sololearn: Learn to code for FREE!

0

Integer in python

When doing numeric operation in python it always returns float. But what if i need integer . Even if the result is a whole number it returns float. Like if the result is 7 it returns 7.0. But i want integer. How can i do that. ( Is there any way to transform float into int.)

9/29/2020 1:59:46 PM

Khalid Shifullah

6 Answers

New Answer

+5

https://code.sololearn.com/cKN5Rdk3CQqv/?ref=app Khalid Shifullah is this what u mean?

+2

Netha_r2071 Thanks a lot bro. This is exactly what i ment.

+1

Khalid Shifullah see the same code using round () function https://code.sololearn.com/cKN5Rdk3CQqv/?ref=app

+1

Netha_r2071 thanks again😍 . dude you are too good

+1

Use int() function πŸ‘πŸ‘

0

Netha_r2071 bro what if i want the output to be rounded. Like if it is 7.8 i want 8. How i do it . import math?