r/PythonLearning • • Nov 01 '26

Help Request Python Quiz of the day.

What will be the output of the following Python Code?

print(pow(2, 5, 7))

0 Upvotes

9 comments sorted by

View all comments

Show parent comment

1

u/RNG_HatesMe Nov 01 '26

Apparently it's much faster with very large numbers because it distributes the mod operation and can keep the magnitudes lower, and therefore uses less memory and processing time.

1

u/TheKnottyOne Nov 01 '26

Yeah that’s what I learned as well. I think there’s a caveat to timing though - the time it takes to complete seems to depend on the value of the exponent