Advertisement
Guest User

pycomputeA

a guest
Apr 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import random
  2. import os
  3. import sys
  4.  
  5. a = random.randint(1,2)
  6. failed = 0
  7. failedtotal = 0
  8. success = 0
  9. recordh = 0
  10. recordl = 100
  11.  
  12. while True:
  13. b = random.randint(1,2)
  14.  
  15. if success == 10000:
  16. print("Experimento terminado, cantidad de aciertos designados: ", success)
  17. print("Total de fallas: ", failedtotal)
  18. print("Promedio de total de fallas: ", failedtotal / success)
  19. print("La mayor cantidad de fallas fue {}, y la menor fue {}".format(recordh,recordl))
  20. break
  21.  
  22. if b == a:
  23. print("Numero encontrado, el numero es: {}".format(a))
  24. print("En total hubieron {} intentos fallidos".format(failed))
  25. a = random.randint(1, 2)
  26. success +=1
  27. failedtotal += failed
  28. if failed > recordh:
  29. recordh = failed
  30. if failed < recordl:
  31. recordl = failed
  32. failed = 0
  33. else :
  34. failed += 1
  35. continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement