for me it looks liked you replyed to this
def is_int(x):
if type(x) == int:
return True
else:
return False
that the problem itself needs math model to be solved. probably just me not understand the forum format
anyways thanks for helping all of us just starting out, big props
I guess i was not thinking about the floor function (which would have made it a bit easier in hindsight). Same principal but more than one way to go about it i suppose.
hey i already passed the exercise but i don’t think i have done it correctly, i have read many topic about it and found many exercise where it said to import this or that and then i found your solution,
i knew what to do, in exerciser it is written exactly what to do, i.e > If the difference between a number and that same number rounded down is greater than zero
which mean the 9.22 - 9 < 0 then it is integer
but i actually didn’t knew how to do it,
thanks to you, i found the solution
The directions said we could not check directly if a number was an int. Here we are converting the number to an int and checking to see if that result is the same as the raw number
def is_int(x):
print x
if int(x) == x:
return True
else:
return False
In this exercise, we are supposed to use arithmetic operations to check if given number is an int. int(x) is a type conversion, but you can cut off the fraction part using arithmetic operation. And you should do that. It’s my opinion, obviously.
also. the print round(15) # => error: TypeError: a float is required part, error was copied from console. not sure why it was giving me that.
In my opinion, this is a lie. But it does not matter. Just please check everything twice before stating that every other solution is wrong and before posting something on the forum for beginner programmers.