Is_int problem


#1



Hi, it is really not complex but I'm not sure how to use the 'round()' function nor the 'math.floor' one.
what is wrong?

Practice Makes Perfect:is_int


Replace this line with your code. 

def is_int(x):
    if round(x)-x==0:
        return True


#2

@tagsurfer82195,
With a google search
round() site:https://en.wikipedia.org/wiki/Python_(programming_language)
you will find
https://en.wikipedia.org/wiki/Python_(programming_language)#Mathematics

Python provides a round function for rounding a float to the nearest integer. 
For tie-breaking, versions before 3 use round-away-from-zero:
    round(0.5) is 1.0, round(-0.5) is −1.0.[70] 
Python 3 uses round-to-even: round(1.5) is 2, round(2.5) is 2.

OR google search
round() site:https://docs.python.org
https://docs.python.org/2/library/functions.html#round

round(number[, ndigits])
Return the floating point value number
 rounded to ndigits digits after the decimal point. 
If ndigits is omitted, it defaults to zero. 
The result is a floating point number.
 Values are rounded to 
the closest multiple of 10 to the power minus ndigits; 
if two multiples are equally close,
 rounding is done away from 0 
(so, for example, round(0.5) is 1.0 and round(-0.5) is -1.0).

Note:
 The behavior of round() for floats can be surprising: for example,
 round(2.675, 2) gives 2.67 instead of the expected 2.68.
 This is not a bug: 
    it’s a result of the fact that most decimal fractions 
   can’t be represented exactly as a float. 
 See Floating Point Arithmetic: 
      Issues and Limitations for more information.

floor() site:https://docs.python.org
https://docs.python.org/2/library/math.html

math.floor(x)
Return the floor of x as a float, 
the largest integer value less than or equal to x

==============================================

nice to know

You could test in labs.codecademy.com
choose Python
You will get a split-screen
In the left-hand-side you paste-in your code
click on the Run button.
The right-hand-side is the console

== the code==

import math

x= 2.65
print math.floor(x)
print round(x,1)

#4