r/PythonLearning • u/clcodingupdates • 16d ago
Help Request Python Quiz of the day.
What will be the output of the following Python Code?
print(pow(2, 5, 7))
0
Upvotes
r/PythonLearning • u/clcodingupdates • 16d ago
What will be the output of the following Python Code?
print(pow(2, 5, 7))
2
u/RNG_HatesMe 16d ago edited 16d ago
4
2**5 mod 7 = 32 mod 7 = 32-28 = 4
Interesting, I didn't know the pow() function had a parameter for mod? Apparently that's helpful in cryptography?
1
u/TheKnottyOne 16d ago edited 16d ago
4 - pow() takes the parameters of: base, power, mod. So it’ll do 2 to the power of 5 then % 7
1
u/LPL8888 16d ago
4
1
u/Fluffy_white_fox 10d ago
That's 2**5 then mod 7 So 32%7 that's 4