python新手。这是我正在看的内容
def input(check):
Check if the input by the user is bigger 0 and assign the user input result (Boolean) to a variable
Check if the input by the user is smaller than 180 and assign the user input result (Boolean) to another variable
如果两个变量都包含true
,则返回true
或其他情况返回False
如何编码?
答案 0 :(得分:1)
input
函数已内置于Python中。
def my_function():
user_input = int(input('Enter a number: ')) # raw_input if Python 2
a = user_input > 0
b = user_input < 180
return a and b # test if both are true
my_function() # call the function
答案 1 :(得分:0)
@Ravi您需要选择其他名称,因为input
用于内置函数。您可以使用NewNameFunction编写所需的函数,如下所示:
def NewNameFunction (check):
a= check > 0
b= check < 180
return (a and b)