1 Star 0 Fork 0

黄津/test_python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test_py24_3_27.py 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
黄津 提交于 2024-04-02 14:53 +08:00 . 第二次实验
import math
def sum(a,b):
return (a+b)
def sub(a,b):
return (a-b)
def mut(a,b):
return (a*b)
def div(a,b):
if(b==0):
return b
return (a/b)
def pycomplex(a,b):
complexoper = input("请输入复数运算")
if complexoper=="+":
print("a+b=",a+b)
return a+b
if complexoper=="-":
print("a-b=",a-b)
return a-b
if complexoper=="*":
print("a*b=",a*b)
return a*b
if complexoper=="/":
print("a/b=",a/b)
return a/b
flag = True
while flag:
a = eval(input("请输入a:"))
b = eval(input("请输入b:"))
operator = input("运算符输入:")
if operator=="+":
print("a+b=",sum(a,b))
if operator=="-":
print("a-b=",sub(a,b))
if operator=="*":
print("a*b=",mut(a,b))
if operator=="/":
if b==0:
print("error")
continue
print("a/b=",div(a,b))
if operator=="com":
pycomplex(a,b)
if operator=="log":
print("log a b=",math.log(b,a))
if operator=="sin":
print("sin(a)=",math.sin(a*3.1415926535/180),",","sin(b)=",math.sin(b*3.1415926535/180))
if operator=="cos":
print("cos(a)=",math.cos(a*3.1415926535/180),",","cos(b)=",math.cos(b*3.1415926535/180))
flag = False if input("是否要继续?Y or N\n")=="N" else True
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/huangjin42953/test_python.git
git@gitee.com:huangjin42953/test_python.git
huangjin42953
test_python
test_python
master

搜索帮助