🌈write in front🌈
🧸大家好,我是Aileen🧸.希望你看完之后,能对你有所帮助,不足请指正!共同学习交流.
🆔本文由Aileen_0v0🧸 原创 CSDN首发🐒 如需转载还请通知⚠️
📝个人主页:Aileen_0v0🧸—CSDN博客
🎁欢迎各位→点赞👍 + 收藏⭐️ + 留言📝
📣系列专栏:Aileen_0v0🧸的PYTHON学习系列专栏——CSDN博客
🗼我的格言:"没有罗马,那就自己创造罗马~"
目录
伪代码:
- year = (int(input()))
- if (year % 100 == 0 and year % 400 == 0) or (year % 100 != 0 and year % 4 == 0):
- print("year是闰年")
- else:
- print("year不是闰年")
tip2:👉🔗http://t.csdnimg.cn/G1ZQ8
- #if- else 法:
- a,b = map(int,input().split())
-
- if a > b:
- max_value = a
- else:
- max_value = b
-
- print(max_value)
-
- #三元换算法: 等价于 原始是a 如果 a > b 就是b
- max_value = a if a > b else b
- print(max_value)
- status = int(input())
-
- match status:
- case 400:
- print("Bad request")
- case 404:
- print("Not found")
- case 418 | 420 | 422 | 400: #| 表示或
- print("I'm a teapot")
- case _: #_ 表示方法
- print("Something's wrong with the internet")
1.字符串中想表示%时,需要写成 %%.
2.Python 中交换两个变量, 可以用: a,b = b,a.
- #零食
- x,y = map(int,input().split())
- if x == 1:
- print("Total: R$ %.2f"%(y * 4))
- elif x == 2:
- print("Total: R$ %.2f"%(y * 4.5))
- elif x == 3:
- print("Total: R$ %.2f"%(y * 5))
- elif x == 4:
- print("Total: R$ %.2f"%(y * 2))
- elif x == 5:
- print("Total: R$ %.2f"%(y * 1.5))
- #写法2:
- x,y = map (int,input().split())
-
- if x == 1:
- p = 4
- elif x == 2:
- p = 4.5
- elif x == 3:
- p = 5
- elif x == 4:
- p = 2
- else:
- p = 1.5
- print("Total : R$ %.2f" % (p * y))
- #加薪
- s = float(input())
-
- if 400 >= s > 0 :
- print("Novo salario: %.2f"%(s * (1+0.15)))
- print("Reajuste ganho: %.2f"%(s * 0.15))
- print("Em percentual: %d %%"%(15))
- elif 800 >= s >= 400.01:
- print("Novo salario: %.2f"%(s * (1+0.12)))
- print("Reajuste ganho: %.2f"%(s * 0.12))
- print("Em percentual: %d %%"%(12))
- elif 1200 >= s >= 800.01:
- print("Novo salario: %.2f"%(s * (1+0.1)))
- print("Reajuste ganho: %.2f"%(s * 0.1))
- print("Em percentual: %d %%"%(10))
- elif 2000 >= s >= 1200.01:
- print("Novo salario: %.2f"%(s * (1+0.07)))
- print("Reajuste ganho: %.2f"%(s * 0.07))
- print("Em percentual: %d %%"%(7))
- else:
- print("Novo salario: %.2f"%(s * (1+0.04)))
- print("Reajuste ganho: %.2f"%(s * 0.04))
- print("Em percentual: %d %%"%(4))
- x = float(input())
-
- if x <= 400:
- y = 15
- elif x <= 800:
- y = 12
- elif x <= 1200:
- y = 10
- elif x <= 2000:
- y = 7
- else:
- y = 4
-
- print("Novo salario:x %.2f" % (x * (1 + y / 100)))
- print("Reajuste ganho: %.2f" % (x * (y / 100)))
- print("Em percentual: %d %" % y)