给出一个演绎推理风格的口头问题,有可能用Python语言解决吗?
如果潜在变量从来没有被赋予真实世界/实值,而是彼此之间的距离,这可以做到吗?这意味着没有固定的起点(即x=1).
我试着从一开始就给所有变量赋值0
,然后从那里开始构建,但我认为这是不正确的.
我在这里有一个示例问题要try ,我已经包括了我想象的代码看起来是什么样子.我知道它不是用完美的PEP8风格写的,所以请不要批评……它更可能是我试图解决问题的一个例子.
"""Denise arrived at the party 1 hour later than Kylie and 30 minutes before James.
Melissa arrived at the party 30 minutes earlier than Denise and 45 minutes earlier than Sarah.
Is the statement below True?
When James arrived, he found both Melissa and Denise enjoying the party and learned that Sarah
arrived at the party 30 minutes prior to him."""
def deductive_reasoning():
kylie = 0
james = 0
denise = 0
sarah = 0
melissa = [denise - 30, sarah - 45]
denise = [kylie + 60, james - 30]
if (james > melissa[0] and melissa[1]) and (james > denise[0] and denise[1]) and (sarah == james - 30):
print("That is true")
else:
print("That is not true")
deductive_reasoning()