Python Divmod and Mod Power

I received via email a couple messages with two easy Python challenges named “Mod Divmod” and “Power – Mod Power”. Following are links to the challenges:

Not much to say. Following is the code for the first challenge:

# -*- coding: utf-8 -*-

# **** read integers ****

a = input()

b = input()

# **** ****

print(int(a) // int(b))

print(int(a) % int(b))

print(divmod(int(a), int(b)))

Following is the code for the second challenge:

# -*- coding: utf-8 -*-

# **** ****

a = int(input())

b = int(input())

c = int(input())

# **** ****

print(pow(a, b))

print(pow(a, b, c))

Implemented the code using the Spyder IDE shipped with Anaconda 3.

Both solutions were accepted each passing two test cases :o)

If you have comments or questions regarding this or any other post in this blog, please do not hesitate and send me a message. I will not use your name unless you explicitly tell me to do so.


Follow me on Twitter:  @john_canessa

Leave a Reply

Your email address will not be published. Required fields are marked *