Send to a Friend

dxs's avatar

Can someone help me with this Python problem?

Asked by dxs (15160points) February 10th, 2015

I’m learning Python in a computer programming class. We looked at how to make exponents (x**y). I want to find the highest number that Python can produce, so I made a function to imput a number into a 10-based exponent. Basically, f(x)=10^x
Here’s what I wrote:

1 import math
2 import time
3 number = int(input(‘number, please:’))
4 start = time.time()
5 alewife = 10**number
6 elapsed = time.time()-start
7 print(“Ten to the power of ” + str(number) + ” is ” + str(alewife))
8 print(“This computation took ” + str(elapsed) + ” seconds”)

I’m on Pycharm. On the bottom of the screen, I get the “Number, please:” prompt. When I enter in a number, it tells me 10 to the power of that number, and how long the computation took.
Now here’s the first problem: The time it takes to compute it is not the same as the time it takes to display it. It says it takes only a few seconds to compute it when it takes a few minutes to display it.
I’m between 106 and 107, since 107 seems too big (it took too long to respond). I did 106.5, 106.25, etc., up to the most recent 106.484375.
Here’s the second problem: With this number, it gave me an answer, but it didn’t print the second line (which tells me how long it took to compute). My guess was that it’s because I ran out of characters.
Any help is appreciated, thanks.

Using Fluther

or

Using Email

Separate multiple emails with commas.
We’ll only use these emails for this message.