7-45 jmu-python- raise (10 minutes)

Enter a group of wage data, write a list. For the wages of less than 5000, up 1.5 times. Wage data and outputs the rise.

Input formats:

Separated by a space data

Output formats:

Data raise, separated by a space. Tail with no spaces.

Sample input:

3000 4000 6000 8000 2000.5

Sample output:

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

  

Guess you like

Origin www.cnblogs.com/aimilu/p/11819157.html