Didn't understand | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Didn't understand

9**(1/2) whay did it print 3.0, not 3?

18th Oct 2017, 9:21 PM
Mehmet Emin Kırgın
Mehmet Emin Kırgın - avatar
4 Answers
+ 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
18th Oct 2017, 9:34 PM
Koketso Dithipe
Koketso Dithipe - avatar
+ 8
Ah, thank you. I knew I did something wrong ¯\_(ツ)_/¯
20th Oct 2017, 8:32 AM
Koketso Dithipe
Koketso Dithipe - avatar
+ 3
Got it, thank you.
18th Oct 2017, 9:36 PM
Mehmet Emin Kırgın
Mehmet Emin Kırgın - avatar
+ 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..
20th Oct 2017, 5:22 AM
sayan chandra
sayan chandra - avatar