Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import timeit
  2.  
  3. def time_m (target):
  4.  
  5. def _decorated (*args, **kwargs):
  6. objetivo={'target':target,'args':args,'kwargs':kwargs}
  7. print(args)
  8. result=timeit.timeit('target(*args, **kwargs)',number=1000,globals=objetivo)
  9. print(f'El tiempo de ejecución es {result}')
  10. return result
  11. return _decorated
  12.  
  13. @time_m
  14. def solve(a, b, c):
  15. """Solves a quadratic equation given the coefficients."""
  16. root = (b**2 - 4*a*c) ** 1/2
  17. return (b + root)/2*a, (b - root)/2*a
  18.  
  19. solve(4, 2, 1)
  20. solve(16, 25, c=5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement