python基础学习day1练习题

1.抹零处理
print("{:#^50}".format("抹零处理"))
price = float(input("请输入价格:"))
num = int(input("请输入数量:"))
money = price*num
ml = int(money) - int(money)%10
print("总价为%.2f,抹零后的价格为%d"%(money,ml))

2.求梯形面积
print("{:#^50}".format("求梯形面积"))
top_line = float(input("请输入上底长度:"))
bottom_line = float(input("请输入下底长度"))
high = float(input("请输入高"))
area = (top_line+bottom_line)*high/2
print("梯形面积为%.2f"%(area))

3.求三位数倒序
print("{:#^50}".format("三位数的倒叙"))
num = int(input("请输入一个是三位数"))
gw = num % 10
sw = num // 10 %10
bw = num // 100
new_n = gw*100 + sw*10 +bw
print("三位数倒置为%d"%(new_n))

4.

'''
下面代码的功能为,如:输入12.345,则输出543.21
'''
num = float(input("请输入类似于abc.ef类型的数字"))
num = num*1000
gw = num%10
sw = num // 10 % 10
bw = num // 100 % 10
qw = num // 1000 % 10
ww = num // 10000
new_n = gw*100 + sw*10 + bw + qw*0.1 +ww*0.01
print("倒置完的数字为%.2f"%new_n)

你可能感兴趣的:(python基础)