大白菜豆腐 2023-03-10 11:54 采纳率: 100%
浏览 54
已结题

关于#python#的问题:用Python解答

img


题目简单,但是比较繁琐,用Python解答,最好可以加一点注释

  • 写回答

4条回答 默认 最新

  • 关注

    (1)单分支

    import math
    
    x = float(input('x='))
    y = math.sin(x) + 2*math.sqrt(x+math.e**4) - (x+1)**3
    if x <0:
        y = math.log(-5*x,math.e) - math.fabs(x**2-8*x)/(7*x)+math.e
    
    print(y)
    
    

    (2)双分支

    import math
    
    x = float(input('x='))
    y = 0
    if x>=0 :
        y = math.sin(x) + 2*math.sqrt(x+math.e**4) - (x+1)**3
    else:
        y = math.log(-5*x,math.e) - math.fabs(x**2-8*x)/(7*x)+math.e
    
    print(y)
    
    

    (3)三条件

    import math
    
    x = float(input('x='))
    if x>0:
        y = math.sin(x) + 2*math.sqrt(x+math.e**4) - (x+1)**3
    elif x <0:
        y = math.log(-5*x,math.e) - math.fabs(x**2-8*x)/(7*x)+math.e
    else:
        y = 2*math.e-1 #这里把x=0的情况单独拿出来把公式简化一下
    
    print(y)
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 3月22日
  • 已采纳回答 3月14日
  • 创建了问题 3月10日

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了