鱼C论坛

 找回密码
 立即注册
查看: 1627|回复: 1

[技术交流] 013

[复制链接]
发表于 2021-8-29 19:14:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
0.相同缩进
1.不能 print没有缩进
2.可以
3.可以
4.不能,缩进不对
----------------------dds
0.

number = int(input("请输入一个整数:"))
if number%2 == 0:
    print(number,"是一个偶数。")
else:
    print(number,"是一个奇数。")
1.
p = int(input("please input the profit of this year:"))
if p <= 10:
    b = p * 0.1
elif 10 < p <= 20:
    b = 10 * 0.1 + (p - 10)*0.075
elif 20 < p <= 40:
    b = 10 * 0.1 + 10*0.075 + (p-20)*0.05
elif 40 < p <= 60:
    b = 10 * 0.1 + 10*0.075 + 20*0.05 + (p-40)*0.03
elif 60 < p <= 100:
    b = 10 * 0.1 + 10*0.075 + 20*0.05 + 20*0.03 +  (p-60)*0.015
elif 100 < p:
    b = 10 * 0.1 + 10*0.075 + 20*0.05 + 20*0.03 + 40*0.015 + (p-100)*0.01
    print("hi")
else:
    print("input is not correct!")

print("the bonus is:",b)

*********************
改错
dds-0
number类型应该是float
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-9-8 12:43:33 | 显示全部楼层
  1. def bonus(amount):
  2.     interest = {
  3.         1000000: 0.01,
  4.         600000: 0.015,
  5.         400000: 0.03,
  6.         200000: 0.05,
  7.         100000: 0.075,
  8.         0: 0.1
  9.     }
  10.     arr = []
  11.     for m in interest.keys():
  12.         if amount >= m and m:
  13.             bal = amount-m
  14.             arr.append(bal*interest[m])
  15.             amount = amount-bal
  16.         elif not m:
  17.             arr.append(amount*interest[0])
  18.     return sum(arr)

  19. print(bonus(1234500))
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-18 22:15

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表