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 import math
print(math.sqrt(-15))
Above code will generate error. import math
x=math.sqrt(25)
print(x) # 5.0
print(type(x)) # <class 'float'>
We can use int() to convert output to integer data type.
import math
x=math.sqrt(25)
y=int(x)
print(type(y)) # <class 'int'>
x1=13639.4
y1=1554.8
x2=13637.5
y2=1570.6
import math
h=math.sqrt((x2-x1)**2 + (y2-y1)**2)
print(h)
We will use round() to limit our output to 2 decimal places.
h=round(math.sqrt((x2-x1)**2 + (y2-y1)**2),2)
Assuming that the input coordinates are in meter , we can get the output in feet and Kadi.
in_feet=h*3.2808
in_kadi=in_feet/0.66
print("Length meeter : ",round(h,2)," Feet:",round(in_feet,2),"
Kadi:",round(in_kadi,2))
Conversion formula is here
1 Feet = 0.3048 Meter
1 Meter = 3.2808 Feet
1 Kadi = 0.66 Feet
Tkinter Application to convert Feet to Meter and vice versa JavaScript Application to convert Feet to Meter and vice versa
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
04-07-2020 | |
| Why the square root of 16 is 4.0 and why not 4??? | |
05-07-2020 | |
| The output of sqrt is float always. Added the part to convert float data type to integer. | |