Elements in the Range
You are given three numbers. Check if any of the numbers exist in the range from 10 to 20 (including 10 and 20).
The first, second, and third lines of input are integers.
The output should be either
True or False
Given
a = 2, b = 4, c = 16 , 16 is in the range between 10 and 20.
So the output should be True
Sample Input 1
2
4
16
Sample Output 1
True
Sample Input 2
2
4
6
Sample Output 2
False
# Python 3.9.5
def enter_numbers():
numbers = []
while len(numbers) < 3:
number = input('Enter number: ')
numbers.append(number)
return numbers
def check_number(numbers):
flag = False
for number in numbers:
if 10 <= int(number) <= 20:
return True
else:
flag = False
return flag
def main():
numbers = enter_numbers()
result = check_number(numbers)
print(result)
if __name__ == '__main__':
main()
Comments
Leave a comment