Skip to content

Commit 1ea3bea

Browse files
committed
Create 1001S02E03_calculator.py
Day 3
1 parent 28d904e commit 1ea3bea

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#告知这是个计算机小程序
2+
print("""请键入要进行运算的两个数字
3+
并按:
4+
“+”代表加
5+
“-”代表减
6+
“*”代表乘
7+
“/”代表除
8+
“%”代表求余数
9+
“**”代表求次方
10+
的如上所示的规则键入你要进行的运算
11+
本程序只可运行一次,重复计算请重复使用
12+
请切换至英文输入模式进行数字和运算的键入""")
13+
#获取要算的数和运算
14+
x = input()
15+
y = input()
16+
z = input()
17+
#计算器程序
18+
if z == "+":
19+
print(x,"+",y,"=",int(x)+int(y))#加法
20+
elif z== "-":
21+
print(x,"-",y,"=",int(x)-int(y))#减法
22+
elif z== "*":
23+
print(x,"*",y,"=",int(x)*int(y))#乘法
24+
elif z== "/":
25+
print(x,"/",y,"=",int(x)/int(y))#除法
26+
elif z== "%":
27+
print(x,"除以",y,"的余数是",int(x)%int(y))#余数
28+
elif z== "**":
29+
print(x,"的",y,"次方是",int(x)**int(y))#次方
30+
31+
32+
33+
34+
35+

0 commit comments

Comments
 (0)