20221406 2022-2023-2 《Python程序设计》实验2报告

#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,问同学

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值