Python引入包
python引入包,直接用import就可以导入,我们下面讲第一个python库,math库
import math
#math函数的第一个用法,math.py是圆周率常数
print(math.pi)
#math.e 是自然常数e
print(math.e)
#math 求绝对值,求出来是float数,跟python自带的abs函数不同,自带的abs是整形
print(math.fabs(-1.01516))
print(abs(-1))
#e的x次方,e的x次方减一
print(math.exp(5))
print(math.expm1(5))
#math.log(x[, base])以x为底的base的对数
print(math.log(2, 5))
#math函数开平方
print(math.sqrt(9))
#求x的天花板数,数轴右边是天花板
print(math.ceil(-2.2))
print(math.ceil(2.2))
#math函数求x的y次方
print(math.pow(3, 2))
#math库,弧度与角度互换
print(math.degrees(math.pi))
print(math.radians(180))
#math 求sin值 cos值 tan值 cot值
print(math.sin(45))
print(math.cos(45))
print(math.tan(45))
#反三角函数
print(math.asin(0.5))
print(math.acos(0.75))
print(math.atan(0.6))
Python流程控制语句
if elif else
#首先我们使用Input函数从控制台读取用户输入
word = int(input("请输入您要选择的菜单,可选输入数字1-5 \n"))
if word < 0 and word > 5:
print("您的输入有误")
elif word == 0:
print("没有菜,滚")
elif word == 1:
print("青椒肉丝1")
elif word == 2:
print("青椒肉丝2")
elif word == 3:
print("青椒肉丝3")
elif word == 4:
print("青椒肉丝4")
else:
print("青椒肉丝5")
for循环