Answer:
import numpy as np
import matplotlib.pyplot as plt
def calculate_pi(x,y):
points_in_circle=0
for i in range(len(x)):
if np.sqrt(x[i]**2+y[i]**2)<=1:
points_in_circle+=1
pi_value=4*points_in_circle/len(x)
return pi_value
length=np.power(10,6)
x=np.random.rand(length)
y=np.random.rand(length)
pi=np.zeros(7)
sample_size=np.zeros(7)
for i in range(len(pi)):
xs=x[:np.power(10,i)]
ys=y[:np.power(10,i)]
sample_size[i]=len(xs)
pi_value=calculate_pi(xs,ys)
pi[i]=pi_value
print("The value of pi at different sample size is")
print(pi)
plt.plot(sample_size,np.abs(pi-np.pi))
plt.xscale('log')
plt.yscale('log')
plt.xlabel('sample size')
plt.ylabel('absolute error')
plt.title('Error Vs Sample Size')
plt.show()
Explanation:
The python program gets the sample size of circles and the areas and returns a plot of one against the other as a line plot. The numpy package is used to mathematically create the circle samples as a series of random numbers while matplotlib's pyplot is used to plot for the visual statistics of the features of the samples.
The web browser that is automatically installed with windows 7 is Internet Explorer.
Hope this helps.
Answer:
This statement is correct.
Explanation:
If a function does not have any parameters, then we can create the variable inside the function which will be private and call the function from the main function.
If we specify any return type like int, float or char, etc then we need to declare a return value from the function.
But If we specify the Void then we don't need to return value inside the function, we can directly print the value inside function.
Ex.
void add()
{
int a=7;
int b=9;
int c=a+b;
System.out.println("the added value is :"+c);
}
Answer:
using a mouse I believe we'll it's the common answer