【帮我解决这个问题,new_weight = 怎么设置。 ][1]
[1]: https://i.stack.imgur.com/IkEdl.jpgprint("我有以下行星的信息:\n") print("我有以下行星的信息:\n")
print(" 1. Venus 2. Mars 3. Jupiter")
print(" 4. Saturn 5. Uranus 6. Neptune\n")
weight = 185
venus = 1
mars = 2
jupiter = 3
saturn = 4
uranus = 5
neptrune = 6
venus_rg = 0.91
mars_rg = 0.38
jupiter_rg = 2.34
saturn_rg = 1.06
uranus_rg = 0.92
neptune_rg = 1.19
inp=input
# Write an if statement below:
inp = input("Enter Planet Number:")
if inp == 1:
weight= weight * 0.91
elif inp == 2:
weight= weight * 0.38
elif inp == 3:
weight = weight * 2.34
elif inp == 4:
weight= weight * 1.06
elif inp == 5:
weight = weight * 0.92
elif inp == 6:
weight = weight * 1.19
print(weight)
答案 0 :(得分:0)
inp = input("Enter Planet Number:")
inp 是一个字符串。所以说他们输入 1,它变成 '1'
。
您需要在它周围调用 int
以将其转换为整数。
所以:
inp = int(input("Enter Planet Number:"))