programming-examples/python/_Basics/Test whether a number is within 100 of 1000 or 2000.py

6 lines
210 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
def near_thousand(n):
return ((abs(1000 - n) <= 100) or (abs(2000 - n) <= 100))
print(near_thousand(1000))
print(near_thousand(900))
print(near_thousand(800))
print(near_thousand(2200))