Latest web development tutorials

hypot Python3 () ฟังก์ชัน

Python3 ดิจิตอล Python3 ดิจิตอล


ลักษณะ

hypot () ผลตอบแทนบรรทัดฐาน sqrt ยุคลิด (X * X + Y * y)


ไวยากรณ์

ต่อไปนี้เป็นไวยากรณ์ hypot () วิธีการ:

import math

math.hypot(x, y)

หมายเหตุ: hypot () ไม่สามารถเข้าถึงได้โดยตรงคุณจำเป็นต้องนำเข้าโมดูลคณิตศาสตร์และจากนั้นเรียกวิธีการจากวัตถุคงคณิตศาสตร์


พารามิเตอร์

  • X - ค่า
  • Y - ค่า

ราคาย้อนกลับ

กลับยุคลิดบรรทัดฐาน sqrt (x * X + Y Y *)


ตัวอย่าง

ต่อไปนี้จะแสดงให้เห็นตัวอย่างของการใช้ 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))

หลังจากทำงานเอาท์พุทตัวอย่างข้างต้นคือ

hypot(3, 2) :  3.605551275463989
hypot(-3, 3) :  4.242640687119285
hypot(0, 2) :  2.0

Python3 ดิจิตอล Python3 ดิจิตอล