简体   繁体   English

无法解决这个python问题我每次都出错

[英]Can't solve this python problem I got error every time

The Bears in Berlin spend most of the day playing.柏林的熊队大部分时间都在玩耍。 In particular, they play if the temperature is between 60 and 90 (inclusive).特别是,如果温度在 60 到 90 度(含)之间,它们就会播放。 Unless it is summer, then the upper limit is 100 instead of 90. Given an int temperature and a boolean is_summer, return True if the Bears play and False otherwise.除非是夏天,否则上限是 100 而不是 90。给定一个整数温度和一个布尔值 is_summer,如果熊队比赛,则返回 True,否则返回 False。 bear_play(70, False) → True bear_play(95, False) → False bear_play(95, True) → True Bear_play(70, False) → True Bear_play(95, False) → False Bear_play(95, True) → True

时间为 python one-liners:

do_bears_play = lambda t, is_summer: 60 <= t <= (100 if is_summer else 90)

The Bears in Berlin spend most of the day playing.柏林的熊队大部分时间都在玩耍。 In particular, they play if the temperature is between 60 and 90 (inclusive).特别是,如果温度在 60 到 90 度(含)之间,它们就会播放。 Unless it is summer, then the upper limit is 100 instead of 90. Given an int temperature and a boolean is_summer, return True if the Bears play and False otherwise.除非是夏天,否则上限是 100 而不是 90。给定一个整数温度和一个布尔值 is_summer,如果熊队比赛,则返回 True,否则返回 False。 bear_play(70, False) → True bear_play(95, False) → False bear_play(95, True) → True Bear_play(70, False) → True Bear_play(95, False) → False Bear_play(95, True) → True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM