Answer to Question #276905 in Python for Pranty

Question #276905

Take two numbers (separated by a space) as user input in a single line



which will be used as a range (both numbers inclusive) later. Your task is



to create and print a Python dictionary where the keys will be numbers from



that range and the corresponding values will be the odd factors (divisors)



of that number in a tuple.




1
Expert's answer
2021-12-07T15:04:56-0500
m, n = input().split()
m, n = int(m), int(n)
if m > n:
	m, n = n,m
res = {}
for i in range(m, n+1):
    tmp = tuple()
    for j in range(1, i+1, 2):
    	if i%j == 0:
    		tmp = (*tmp, j)
    res[i] = tmp
print(res)




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS