Python hypot() 函数

栏目: 编程语言 · Python · 编程教程 · python 教程 · 发布时间: 7年前

内容简介:hypot() 返回欧几里德范数 sqrt(x*x + y*y)。

描述

hypot() 返回欧几里德范数 sqrt(x*x + y*y)。

语法

以下是 hypot() 方法的语法:

import math

math.hypot(x, y)

注意:hypot()是不能直接访问的,需要导入 math 模块,然后通过 math 静态对象调用该方法。

参数

  • x -- 一个数值。
  • y -- 一个数值。

返回值

返回欧几里德范数 sqrt(x*x + y*y)。

实例

以下展示了使用 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)

以上实例运行后输出结果为:

hypot(3, 2) :  3.60555127546
hypot(-3, 3) :  4.24264068712
hypot(0, 2) :  2.0

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Effective JavaScript

Effective JavaScript

David Herman / Addison-Wesley Professional / 2012-12-6 / USD 39.99

"It's uncommon to have a programming language wonk who can speak in such comfortable and friendly language as David does. His walk through the syntax and semantics of JavaScript is both charming and h......一起来看看 《Effective JavaScript》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

html转js在线工具
html转js在线工具

html转js在线工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试