File tree Expand file tree Collapse file tree
script_library/scripts/basic Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ def Menu (): #定义界面
2+ print (('-' * 20 ))
3+ print ('简易数学计算器系统1.0' )
4+ print ('1.加法运算 2.减法运算 3.乘法运算' )
5+ print ('4.除法运算 0.退出系统' )
6+ print (('-' * 20 ))
7+
8+ def jia (): #定义加法函数
9+ a = float (input ('请输入加数1:' ))
10+ b = float (input ('请输入加数2:' ))
11+ c = a + b
12+ print ('和为:' ,c )
13+
14+ def jian (): #定义减法函数
15+ d = float (input ('请输入被减数:' ))
16+ e = float (input ('请输入减数:' ))
17+ f = d - e
18+ print ('差为:' ,f )
19+
20+ def cheng (): #定义乘法函数
21+ g = float (input ('请输入乘数1:' ))
22+ h = float (input ('请输入乘数2:' ))
23+ i = g * h
24+ print ('积为:' ,i )
25+
26+ def chu (): #定义除法函数
27+ j = float (input ('请输入被除数:' ))
28+ k = float (input ('请输入除数:' ))
29+ l = j / k
30+ print ('商为:' ,l )
31+
32+ def main (): #定义主控制台
33+ while True :
34+ Menu ()
35+ key = input ('请输入对应功能的数字:' )
36+ if key == '1' :
37+ jia ()
38+ elif key == '2' :
39+ jian ()
40+ elif key == '3' :
41+ cheng ()
42+ elif key == '4' :
43+ chu ()
44+ elif key == '0' :
45+ q = input ('是否退出系统?(y or n):' )
46+ if q == 'y' :
47+ print ('已退出系统' )
48+ break
49+ else :
50+ print ('没有对应此数字的功能!' )
51+
52+ main () #调用主函数
53+
54+
You can’t perform that action at this time.
0 commit comments