+ 2
Didn't understand
9**(1/2) whay did it print 3.0, not 3?
4 Respuestas
+ 9
in python, the division operator returns floats, like 10/2 will return 5.0. Try:
9**1//2. it will return an integer (no decimal points), I think this is called Floor Division. I'm not sure, I trust someone will correct me if I'm wrong
+ 8
Ah, thank you. I knew I did something wrong ¯\_(ツ)_/¯
+ 3
Got it, thank you.
+ 2
first of all...
its all wrong what you have replied#####
9**(1//2) will give answer as 1
not 3...
9**(1//2)
=9**(0)## which means 9^0
=1
what u have to do is ...
int(9**(1/2))
means..int(3.0) which is 3...
####
but its not a good practice for numbers that aren't perfect square...
so....cause in this way...int(10**(1/2)) will also returns 3...but
root(10) is greater than 3...
and remember take / operator as normal division operator...it gives you perfect value after division...
whether its 2 or 2.5 or 2.98...more precise
but // is simply quivalent to
a//b=int(a/b)
only integer part of entire division answer..