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