• 牛客网刷题-(6)


     🌈write in front🌈
    🧸大家好,我是Aileen🧸.希望你看完之后,能对你有所帮助,不足请指正!共同学习交流.
    🆔本文由Aileen_0v0🧸 原创 CSDN首发🐒 如需转载还请通知⚠️
    📝个人主页:Aileen_0v0🧸—CSDN博客
    🎁欢迎各位→点赞👍 + 收藏⭐️ + 留言📝​
    📣系列专栏:Aileen_0v0🧸的PYTHON学习系列专栏——CSDN博客
    🗼我的格言:"没有罗马,那就自己创造罗马~" 

    目录

    (1)闰年判断

    (2)判断大小

    (3)零食

    (4)加薪


    (1)闰年判断

    伪代码:

    1. year = (int(input()))
    2. if (year % 100 == 0 and year % 400 == 0) or (year % 100 != 0 and year % 4 == 0):
    3. print("year是闰年")
    4. else:
    5. print("year不是闰年")

     tip2:👉🔗http://t.csdnimg.cn/G1ZQ8

    (2)判断大小

    1. #if- else 法:
    2. a,b = map(int,input().split())
    3. if a > b:
    4. max_value = a
    5. else:
    6. max_value = b
    7. print(max_value)
    8. #三元换算法: 等价于 原始是a 如果 a > b 就是b
    9. max_value = a if a > b else b
    10. print(max_value)

    Match 语句: 

    1. status = int(input())
    2. match status:
    3. case 400:
    4. print("Bad request")
    5. case 404:
    6. print("Not found")
    7. case 418 | 420 | 422 | 400: #| 表示或
    8. print("I'm a teapot")
    9. case _: #_ 表示方法
    10. print("Something's wrong with the internet")

    1.字符串中想表示%时,需要写成 %%.

    2.Python 中交换两个变量, 可以用: a,b = b,a.

    (3)零食

     

    写法1:

    1. #零食
    2. x,y = map(int,input().split())
    3. if x == 1:
    4. print("Total: R$ %.2f"%(y * 4))
    5. elif x == 2:
    6. print("Total: R$ %.2f"%(y * 4.5))
    7. elif x == 3:
    8. print("Total: R$ %.2f"%(y * 5))
    9. elif x == 4:
    10. print("Total: R$ %.2f"%(y * 2))
    11. elif x == 5:
    12. print("Total: R$ %.2f"%(y * 1.5))

     写法2:

    1. #写法2:
    2. x,y = map (int,input().split())
    3. if x == 1:
    4. p = 4
    5. elif x == 2:
    6. p = 4.5
    7. elif x == 3:
    8. p = 5
    9. elif x == 4:
    10. p = 2
    11. else:
    12. p = 1.5
    13. print("Total : R$ %.2f" % (p * y))

    (4)加薪

     

    方法1: 

    1. #加薪
    2. s = float(input())
    3. if 400 >= s > 0 :
    4. print("Novo salario: %.2f"%(s * (1+0.15)))
    5. print("Reajuste ganho: %.2f"%(s * 0.15))
    6. print("Em percentual: %d %%"%(15))
    7. elif 800 >= s >= 400.01:
    8. print("Novo salario: %.2f"%(s * (1+0.12)))
    9. print("Reajuste ganho: %.2f"%(s * 0.12))
    10. print("Em percentual: %d %%"%(12))
    11. elif 1200 >= s >= 800.01:
    12. print("Novo salario: %.2f"%(s * (1+0.1)))
    13. print("Reajuste ganho: %.2f"%(s * 0.1))
    14. print("Em percentual: %d %%"%(10))
    15. elif 2000 >= s >= 1200.01:
    16. print("Novo salario: %.2f"%(s * (1+0.07)))
    17. print("Reajuste ganho: %.2f"%(s * 0.07))
    18. print("Em percentual: %d %%"%(7))
    19. else:
    20. print("Novo salario: %.2f"%(s * (1+0.04)))
    21. print("Reajuste ganho: %.2f"%(s * 0.04))
    22. print("Em percentual: %d %%"%(4))

    方法2: 

    1. x = float(input())
    2. if x <= 400:
    3. y = 15
    4. elif x <= 800:
    5. y = 12
    6. elif x <= 1200:
    7. y = 10
    8. elif x <= 2000:
    9. y = 7
    10. else:
    11. y = 4
    12. print("Novo salario:x %.2f" % (x * (1 + y / 100)))
    13. print("Reajuste ganho: %.2f" % (x * (y / 100)))
    14. print("Em percentual: %d %" % y)

  • 相关阅读:
    旅游卡免费旅游的使用条件有哪些?
    MySQL热点行更新
    HCIA自学笔记01-冲突域
    nacos-springboot搭建
    pdf编辑软件哪个好用?5款PDF编辑器分享
    【JavaEE初阶】多线程 _ 基础篇 _ 线程池(案例四)
    本地客户端连接阿里云Redis服务器
    关于Coinbase成长历程的感悟 2021-04-15
    Android13---下拉状态栏添加阅读模式(MTK平台)
    DataCube 漏洞小结
  • 原文地址:https://blog.csdn.net/Aileenvov/article/details/134069636