Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. """
  2. 3.11
  3. """
  4. from random import randint
  5. import matplotlib
  6. import matplotlib.pyplot as plt
  7.  
  8. x1 = []
  9. y1 = []
  10.  
  11. def experiment(N):
  12. n = 0
  13. for i in range(N):
  14. x = randint(0, 60)
  15. y = randint(0, 60)
  16.  
  17. if (x + 10 >= y) and (y + 12 >= x):
  18. n += 1
  19. x1.append(x)
  20. y1.append(y)
  21. #else:
  22. #x2.append(x)
  23. #y2.append(y)
  24.  
  25. return (n / N)
  26.  
  27.  
  28. print("Answer:")
  29. print(experiment(10000))
  30. print(len(x1), len(y1))
  31. plt.plot(x1, y1, linestyle="", marker="o", color = "g")
  32. #plt.plot(x2, y2, linestyle="", marker="o", color = "r")
  33. plt.title('PLOT')
  34. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement