跳到主要内容

Python 求平方运算

alpha    2019年8月22日 08:27:21

  1. 使用表达式
  2. 使用内置模块
  3. 使用内置函数
# 1. 表达式
c = 3**2
# 2. 内置模块
import math
a = math.pow(3,2)
# 3. 内置函数
b = pow(3,2)
# 注意:这个不是平方,^是按位异或逻辑运算符,&是按位逻辑运算符,|是按位或逻辑运算符
d = 3^2
print(a, b, c, d)
运行结果(手动添加了换行):
9.0
9
9
1
最近更新: 2019年8月22日 08:29:19
浏览: 2.3K

[[total]] 条评论

添加评论
  1. [[item.time]]
    [[item.user.username]] [[item.floor]]楼
  2. 点击加载更多……
  3. 添加评论