In: Computer Science
Python!
Create a program that does the following:
Create 2 functions findDivisors() and lucky7(). Use docstrings to explain what each function does. Use the help() function to output the docstring at the end of your program.
def findDivisors(number):
'''
This function creates an empty list. For every integer from 1 to
number, number is divided by i
to check if remainder is zero(exactly divisible) if yes it will be
added to list. This lst will be returned to caller
'''
lst=[]
i = 1
while i <= number :
if (number % i==0) :
lst.append(i)
i = i + 1
return lst
def lucky7(number):
'''
This function checks if the given number is divisible by 7
exactly
if yes returns true otherwise false
'''
if number%7==0:
return True
else:
return False
number=input('Enter a number: ')
while number!='q':
number=int(number)
print("Divisors of ",number," : ",findDivisors(number))
if(lucky7(number)):
print("7 is a divisor of ",number)
else:
print("7 is not a divisor of ",number)
number=input('Enter a number: ')
help(findDivisors)
help(lucky7)