forked from arnavjindal/python-programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpracticeProblem-2.py
46 lines (40 loc) · 1.21 KB
/
practiceProblem-2.py
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
33
34
35
36
37
38
39
40
41
42
43
44
# This task consists of a total of 10 points to evaluate your performance.
#
# Problem Statement:-
# Harry Potter has got the “n” number of apples. Harry has some students among whom he wants to distribute the apples. These “n” number of apples is provided to harry by his friends, and he can request for few more or few less apples.
#
# You need to print whether a number is in range mn to mx, is a divisor of “n” or not.
#
# Input:
#
# Take input n, mn, and mx from the user.
#
# Output:
# Print whether the numbers between mn and mx are divisor of “n” or not. If mn=mx, show that this is not a range, and mn is equal to mx. Show the result for that number.
#
# Example:
# If n is 20 and mn=2 and mx=5
#
# 2 is a divisor of20
#
# 3 is not a divisor of 20
#
# …
#
# 5 is a divisor of 20
try:
a, mn, mx = input("enter n, mn, mx seperated by space: ").split()
a,mn,mx =int(a),int(mn),int(mx)
except ValueError:
print("enter integer values only")
exit()
if mn == mx or a<0:
print("enter a valid range")
exit()
if mn >mx:
print("enter mx greater than mn")
for i in range(mn,mx+1):
if a%i==0:
print(f'{i} is a divisor of {a}')
else:
print(f'{i} is not a divisor of {a}')