我是一个新的python,我想测试它,我的想法是制作一个脚本,这将看到你可以购买多少东西一定数量的钱.这个项目的问题是,我不知道删除小数,就像你喜欢如果你有1,99美元和苏打水花费2美元,你在技术上将没有足够的钱.这是我的脚本:
Banana = 1
Apple = 2
Cookie = 5
money = input("How much money have you got? ")
if int(money) >= 1:
print("For ", money," dollars you can get ",int(money)/int(Banana),"bananas")
if int(money) >= 2:
print("Or ", int(money)/int(Apple), "apples")
if int(money) >= 5:
print("Or ", int(money)/int(Cookie)," cookies")
else:
print("You don't have enough money for any other imported elements in the script")
Run Code Online (Sandbox Code Playgroud)
现在,如果我输入例如9,在这个脚本中,它会说我可以获得1.8个cookie,我怎么说它在输入fx 9时我可以获得1个cookie?