# JOALTER

 博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅  :: 管理

# 学号 2019-2020-2 《Python程序设计》实验2报告

## 1.实验内容

• 设计并完成一个完整的应用程序，完成加减乘除模等运算，功能多多益善。
• 考核基本语法、判定语句、循环语句、逻辑运算等知识点

## 2. 实验过程及结果

t是循环成立的Bloor元素

def get_number_for_use(sq):
if sq == '1':
pass
elif sq == '2':
sub()
pass
elif sq == '3':
mul()
pass
elif sq == '4':
div()
pass
elif sq == '5':
flo_div()
pass
elif sq == '6':
mod()
pass
elif sq == '7':
power()
pass
else:
print("\n输入错误！")
return


def add():
fr = int(input("\n请输入加数"))
se = int(input("请输入加数"))
print(fr,"+",se,"=",fr + se)
pass

def sub():
fr = int(input("\n请输入被减数"))
se = int(input("请输入减数"))
print(fr,"-",se,"=",fr - se)
pass

def mul():
fr = int(input("\n请输入乘数"))
se = int(input("请输入乘数"))
print(fr, "X", se, "=", fr * se)
pass

def div():
fr = int(input("\n请输入被除数"))
se = int(input("请输入除数"))
print(fr, "/", se, "=", fr / se)
pass

def flo_div():
fr = int(input("\n请输入被地板除的数"))
se = int(input("请输入除数"))
print(fr, "floor division", se, "=", fr // se)
pass

def mod():
fr = int(input("\n请输入被模数"))
se = int(input("请输入模"))
print(fr,"Mod(",se,")=",fr % se)
pass

def power():
fr = int(input("\n请输入底数"))
se = int(input("请输入指数"))
print(fr, "^", se, "=", fr ** se)
pass


## ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂

def get_number_for_use(sq):
if sq == '1':
pass
elif sq == '2':
sub()
pass
elif sq == '3':
mul()
pass
elif sq == '4':
div()
pass
elif sq == '5':
flo_div()
pass
elif sq == '6':
mod()
pass
elif sq == '7':
power()
pass
else:
print("\n输入错误！")
return

fr = int(input("\n请输入加数"))
se = int(input("请输入加数"))
print(fr,"+",se,"=",fr + se)
pass

def sub():
fr = int(input("\n请输入被减数"))
se = int(input("请输入减数"))
print(fr,"-",se,"=",fr - se)
pass

def mul():
fr = int(input("\n请输入乘数"))
se = int(input("请输入乘数"))
print(fr, "X", se, "=", fr * se)
pass

def div():
fr = int(input("\n请输入被除数"))
se = int(input("请输入除数"))
print(fr, "/", se, "=", fr / se)
pass

def flo_div():
fr = int(input("\n请输入被地板除的数"))
se = int(input("请输入除数"))
print(fr, "floor division", se, "=", fr // se)
pass

def mod():
fr = int(input("\n请输入被模数"))
se = int(input("请输入模"))
print(fr,"Mod(",se,")=",fr % se)
pass

def power():
fr = int(input("\n请输入底数"))
se = int(input("请输入指数"))
print(fr, "^", se, "=", fr ** se)
pass

print("=" * 10, "计算器", "=" * 10)

data1 = ["加法", "减法", "乘法", "除法", "底板除", "求模", "求幂"]
num = 0
t = True

while t:
num = 0
print("\n请输入对应数字来进行相应操作")
for item in data1:
num += 1
print(num, item)
a = input("请输入：")
get_number_for_use(a)

b = input("\n是否要继续，是请输入 y ，否请输入 n :")
while True:
if b == 'y':
break
elif b == 'n':
t = False
break
else:
b = input("\n输入错误，请重新输入:")



## 参考资料

posted on 2020-04-12 14:26  JOALTER  阅读(75)  评论(1编辑  收藏