7-45 jmu-python-涨工资 (10 分)


输入一组工资数据,写入列表。对于小于5000的工资,涨1.5倍。并输出涨后的工资数据。

输入格式:

数据之间空格隔开

输出格式:

涨工资后的数据,空格隔开。尾部 不带空格。

输入样例:

3000 4000 6000 8000 2000.5

输出样例:

4500.0 6000.0 6000 8000 3000.75
s = input()
ls = []
ls = s.split()
cnt = 0
for i in ls:
    i = float(i)
    if i <= 5000 and cnt == 1:
        if i - int(i) > 0:
            print(" {:.2f}".format(i * 1.5), end="")
        else :
            print(" {:.1f}".format(i*1.5),end="")
    elif i > 5000 and cnt == 1:
        print(" {:d}".format(int(i)),end="")
    if cnt == 0:
        if i <= 5000:
            if i - int(i) > 0:
                print("{:.2f}".format(i * 1.5), end="")
                cnt = 1
            else:
                print("{:.1f}".format(i * 1.5), end="")
                cnt = 1
        else:
            print("{:d}".format(int(i)), end="")
            cnt = 1

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM