Ai
1 Star 0 Fork 0

宗俊豪/Pythonwork

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
计算器.py 1.27 KB
Copy Edit Raw Blame History
宗俊豪 authored 2020-04-11 19:37 +08:00 . 计算器
"""作者:20192413宗俊豪
文件名称:计算器
时间:2020.4.11"""
import math
"""加法"""
def jia(x, y):
return x + y
"""减法"""
def jian(x, y):
return x - y
"""乘法"""
def cheng(x, y):
return x * y
"""除法"""
def chu(x, y):
return x / y
print("选择运算:")
print("1、相加")
print("2、相减")
print("3、相乘")
print("4、相除")
xunhuan=1
while(xunhuan):
choice = input("输入你的选择:")
if choice == '1':
num1 = float(input("输入第一个数字: "))
num2 = float(input("输入第二个数字: "))
print(num1, "+", num2, "=", jia(num1, num2))
elif choice == '2':
num1 = float(input("输入第一个数字: "))
num2 = float(input("输入第二个数字: "))
print(num1, "-", num2, "=", jian(num1, num2))
elif choice == '3':
num1 = float(input("输入第一个数字: "))
num2 = float(input("输入第二个数字: "))
print(num1, "*", num2, "=", cheng(num1, num2))
elif choice == '4':
num1 = float(input("输入第一个数字: "))
num2 = float(input("输入第二个数字: "))
print(num1, "/", num2, "=", chu(num1, num2))
else:
print("输入错误")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zjh2413/Pythonwork.git
git@gitee.com:zjh2413/Pythonwork.git
zjh2413
Pythonwork
Pythonwork
master

Search