-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexercise_18.py
More file actions
32 lines (26 loc) · 780 Bytes
/
exercise_18.py
File metadata and controls
32 lines (26 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
print(
'-----------------------------------------\n'\
'Practical python education || Exercise-18:\n'\
'-----------------------------------------\n'
)
print(
'Task:\n'\
'-----------------------------------------\n'\
'Write a Python program to test whether a number is within 100 of 1000 or 2000."\n'
)
print(
'Solution:\n'\
'-----------------------------------------'\
)
def near_thousand(n):
return ((abs(1000 - n) <= 100) or (abs(2000 - n) <= 100))
print(near_thousand(534))
print(near_thousand(956))
print(near_thousand(1101))
print(near_thousand(1899))
print(near_thousand(2003))
print(
'\n-----------------------------------------\n'\
'Copyright 2018 Vladimir Pavlov. All Rights Reserved.\n'\
'-----------------------------------------'
)