Latest web development tutorials

Python3 Hypot () function

Python3 digital Python3 digital


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/python3
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.605551275463989
hypot(-3, 3) :  4.242640687119285
hypot(0, 2) :  2.0

Python3 digital Python3 digital