在下面的程序中,我需要从变量“b”中减去bartype,然后在一段代码中从2.5中去掉前导零
我试过在代码的不同位置移动减法
b=int(input('Please enter weight to load on the bar:'))
bartype=int(input('Please enter bar weight'))
x = bartype
b = (b-x)
print(b//45, "45's")
b = b%45
print(b//25, "25's")
b = b%25
print(b//10, "10's")
b = b%10
# I need to print 2.5 without leading zeros
print(b/2.5, "2.5's")
b = b%2.5
print(b//5, "5's")
b = b%5
所以这里有一个例子365=365-bartype,然后应该分解权重类型(45、25等)。答案应该是6 45's 2 25's。示例320应该等于6 45's和2 2.5's
相关问题 更多 >
编程相关推荐