The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Why is int() not rounding to the nearest whole number?

Why is int() not rounding to the nearest whole number?

0
Votes
1
Answer

when we write any decimal with int why the comes with small whole number
 
e.g  int (4.9)
        out 4
 
why the output doesn’t come nearest whole number
 
e.g  int (4.9)
        out 5

1 Answer

365 Team
0
Votes

Hi Alexis,
 
Thanks for reaching out!
 
The int() function returns the integer part of a real number.
If you want the nearest integer number, you can use the round() function:
 

 
Best,
The 365 Team