Python Hypot () function
deskripsi
Hypot () Mengembalikan norma sqrt Euclidean (x * x + y * y).
tatabahasa
Berikut ini adalah metode sintaks Hypot ():
import math math.hypot(x, y)
Catatan: Hypot () tidak langsung dapat diakses, Anda perlu mengimpor modul matematika, dan kemudian memanggil metode dengan matematika objek statis.
parameter
- x - nilai.
- y - nilai.
Kembali Nilai
Kembali Euclidean norma sqrt (x * x + y * y).
contoh
Berikut ini menunjukkan contoh penggunaan () metode Hypot:
#!/usr/bin/python import math print "hypot(3, 2) : ", math.hypot(3, 2) print "hypot(-3, 3) : ", math.hypot(-3, 3) print "hypot(0, 2) : ", math.hypot(0, 2)
Setelah menjalankan contoh di atas output:
hypot(3, 2) : 3.60555127546 hypot(-3, 3) : 4.24264068712 hypot(0, 2) : 2.0