TheAceHome

Untitled

Oct 14th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #3.14
  2. import random
  3. from random import randint
  4. import matplotlib
  5. import matplotlib.pyplot as plt
  6.  
  7. N=100000
  8. a,b=[],[]
  9. n=0
  10. for i in range (N):
  11. x=random.uniform(0,1)
  12. y=random.uniform(0,1)
  13. if (x+y<1) and (x*y<2/9):
  14. a.append(x)
  15. b.append(y)
  16. n+=1
  17. print(n/N)
  18. plt.plot(a,b, linestyle="",marker="o")
  19. plt.title('PLOT')
  20. plt.show()
Add Comment
Please, Sign In to add comment