You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
627 B
35 lines
627 B
2 years ago
|
from timeit import default_timer as timer
|
||
|
import time
|
||
|
|
||
|
def calc_square(numbers, verbose=False):
|
||
|
for n in range(1,numbers):
|
||
|
q= n*n
|
||
|
if verbose:
|
||
|
print(f'\n{n} ^ 2 = {q}')
|
||
|
time.sleep(0.1)
|
||
|
|
||
|
def calc_cube(numbers,verbose=False):
|
||
|
for n in range(1,numbers):
|
||
|
k = n*n*n
|
||
|
if verbose:
|
||
|
print(f'\n{n} ^ 3 = {k}')
|
||
|
time.sleep(0.1)
|
||
|
|
||
|
start = timer()
|
||
|
|
||
|
calc_square(100,True)
|
||
|
calc_cube(100,True)
|
||
|
|
||
|
ende = timer()
|
||
|
differenz = ende - start
|
||
|
print(f'Zeit mit print():{differenz}s')
|
||
|
|
||
|
start = timer()
|
||
|
|
||
|
calc_square(100)
|
||
|
calc_cube(100)
|
||
|
|
||
|
ende = timer()
|
||
|
differenz = ende - start
|
||
|
print(f'Zeit ohne print():{differenz}s')
|