Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. def volume(a,b,c,c1,n):
  2.     '''Returns the volume of a rectangular Parallelepiped height c1 inside the same surface abc, Monte Carlo method'''
  3.     m = 0 # counts points inside height c1
  4.     v = a*b*c # volume of surface abc
  5.     for i in range(0,n): # n determines number of points generated
  6.         z = random.uniform(0,c) # random height
  7.         if z <= c1: # if inside height c1
  8.             m += 1
  9.     v1 = m/n * v # Ratio between points inside and outside
  10.     return v1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement