30 Day code challenge-python

--

Day 19— Interfaces

Task

Complete the implementation of Calculator class, which implements the AdvancedArithmetic interface. The implementation for the divisorSum(n) method must return the sum of all divisors of n.

Sample input and output

Input Format

A single line with an integer, n.

Output Format

The locked template code in the editor below will call your code and print the necessary output.

Solution

Explanation

Line 14–15: Gets input from the user and calls the class function divisorSum()

Line 5–11: Prints the sum of divisor of the specific value by the condition “if n%i ==0”

Line 17–18: Prints the final output

Bonus Tip: Attribute __bases__ is the tuple of class objects given as the base classes in the class statement.

See you on day 20

--

--

No responses yet