1 Star 0 Fork 0

耿翔宇 / pythonProject5

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
模拟运算.py 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
耿翔宇 提交于 2021-05-25 22:44 . python
# a = 10
# b = 20
def operation(a, b, operator):#形参,默认值
# 计算机
# 输入两个数a和b,计算a和b的操作:+、-、*、/、//、%、**、sin、cos、tan、cot
a = float(input("请输入一个数a:"))
b = float(input("请输入一个数b:"))
#def operation2(*para):
#sum1 = 0
#for item in para:
#sum1 = sum1+item
#print("多个数的和是:", sum1)
flag = 1
#list1=[]
while flag == 1:
operator = input("请输入你要做的运算吧(+、-、*、/、//、%、**、sin、cos、tan、cot):")
a = float(input("请输入一个数a:"))
b = float(input("请输入一个数b:"))
if operator == "+":
print("a" + operator + "b= ", operation(a, b, operator))
elif operator == "-":
print("a" + "_" + "b= ", operation(a, b, operator))
flag = int(input("继续(1)或退出(0)?"))
elif operator == "**":
print("a" + "operator" + "b= ", operation(a, b, operator)) # 关键子参数
flag = int(input("继续(1)或退出(0)?"))
c = int(input("请输入一个数c:"))
d = int(input("请输入一个数d:"))
print("c和d的和是:", c + d)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/geng-xiangyu/pythonProject5.git
git@gitee.com:geng-xiangyu/pythonProject5.git
geng-xiangyu
pythonProject5
pythonProject5
第三次作业

搜索帮助

344bd9b3 5694891 D2dac590 5694891