Python Code- Will my code work?
Posted: Sat Dec 28, 2019 9:00 pm
Hello! My science fair project is "How Fast Do Computers Calculate Arithmetic Equations?" However, I'm not sure if my code will produce a correct output. I am using a Macbook for my computer, Python for the coding language and IDLE.app for running the code. I reached out to a coding teacher over email, and he showed me a code that worked on his computer. He attached a screenshot, which showed the code did work and produced an accurate output. However, when I entered the code on my computer, it did not work! He was running the code on a program that was not IDLE, and the computer seemed to be a Windows (it did not look as if it was a Mac). How can I change the code to make it work for my family's Macbook and on IDLE? Thank you in advance! This is the code I attempted to use:
from timeit import default_timer as timer
def howlong():
start = timer()
code_to_test = ""
a = range(100000)
b = []
for i in a:
b.append(i*2)
x = 10
y = 40
z = x + y
stop = timer() - start
print(stop)
print(z)
from timeit import default_timer as timer
def howlong():
start = timer()
code_to_test = ""
a = range(100000)
b = []
for i in a:
b.append(i*2)
x = 10
y = 40
z = x + y
stop = timer() - start
print(stop)
print(z)