age = int(input('Enter your age: '))
print('How old are you?',age)
x = (.5(age)-13)
y = (.5(age)+13)
print('You can date people between', x, 'and', y)
我意识到无论出于何种原因,年龄都变成了浮动。我如何修改它,以便年龄成为我可以在给定方程式中使用的东西?我想剥离它或尝试将其转换为int?
答案 0 :(得分:4)
age是一个int,乘以0.5给出一个float结果,使用// 2得到商(* 0.5相当于/ 2)
age = int(input('Enter your age: '))
print('How old are you?',age)
x = age//2-13
y = age//2+13
print('You can date people between', x, 'and', y)