Respuesta :
Program explanation:
- In the given program code, a method "sum_divisors" is declared that takes "n" variable in its parameter.
- Inside the method, the "s" variable is declared, which holds a value which is "0", and used a for loop that defines counts the range values.
- In the loop, a conditional statement is declared that check remainder value equal to 0 and adds value in "s" variable and return its value.
Program code:
def sum_divisors(n):#defining a method sum_divisors that takes a parameter
s = 0#defining a variable s that hold a value 0
for x in range(1,n):#defining a for loop that use n variable to check range value
if(n%x==0):#use if to check remainder value equal to 0
s += x#adding value in s variable
return s#return s value
print(sum_divisors(6))#calling method
print(sum_divisors(12))#calling method
Output:
Please find the attached file.
Learn more:
brainly.com/question/14704583
