sqrt(x) returns squqre root of input number as float data type.
import math
print(math.sqrt(4))    # 2.0 
print(math.sqrt(16))   # 4.0 
print(math.sqrt(20))   # 4.47213595499958
print(math.sqrt(0))    # 0.0
Using negative number
For any value less than 0 , we will get ValueError
import math
Above code will generate error.

Output of math.sqrt() is float data type. We can use type() to get the data type.
import math
print(x)        # 5.0
print(type(x))  # <class 'float'>
We can use int() to convert output to integer data type.
import math
print(type(y))  # <class 'int'>
log10 modf()



Why the square root of 16 is 4.0 and why not 4???


The output of sqrt is float always. Added the part to convert float data type to integer.

Post your comments , suggestion , error , requirements etc here

Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2021 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer