#20221406 2022-2023-2 《Python程序设计》实验2报告
课程:《Python程序设计》
班级: 2214
姓名: 李昊未
学号:20221406
实验教师:王志强
实验日期:2023年3月24日
必修/选修: 公选课
##1.实验内容
设计并完成一个完整的应用程序,完成加减乘除模等运算,功能多多益善。
考核基本语法、判定语句、循环语句、逻辑运算等知识点
##2. 实验过程及结果
import math def add(a,b): print("a+b=",a+b) def sub(a,b): print("a-b=",a-b) def mul(a,b): print("a*b=",a*b) def div(a,b): if b!=0: print("a/b=",a/b) else: print("error") def log(a,b): print("logab=",math.log(b,a)) def yu(a,b): print("a%b=",a%b) while True: a = int(input("input the first number:\n")) b = int(input("input the second number:\n")) print(""" Functions: 1.addition 2.subtraction 3.multiply 4.division 5.log 6.yu 7.quit """) choice=input("choose the function") if choice=="1": add(a,b) elif choice=="2": sub(a,b) elif choice=="3": mul(a,b) elif choice=="4": div(a,b) elif choice=="5": log(a,b) elif choice=="6": yu(a,b) elif choice=="7": print("thanks") break else: print("error") 调试结果:
运行结果:
码云:
##3. 实验过程中遇到的问题和解决过程
问题1:对于将代码上传到码云的步骤依然不熟练
解决:查csdn,问同学