Professional Documents
Culture Documents
Implementation of Function and Estimating Pi Value Using Monte-Carlo Simulation in Python - Lab - Assignment - 02 - Solution - Muhammad - Noman
Implementation of Function and Estimating Pi Value Using Monte-Carlo Simulation in Python - Lab - Assignment - 02 - Solution - Muhammad - Noman
Implementation of Function and Estimating Pi Value Using Monte-Carlo Simulation in Python - Lab - Assignment - 02 - Solution - Muhammad - Noman
1. Make sure that you understand the concepts of assignment #1 and you have a running
code for that.
2. Create a file “distance_script.py”
3. Copy paste your code from yesterday and create a function called getDistance
4. This function can be called as
getDistance(phi_1,lambda_1,phi_2,lambda_2)
5. Make a call to the function
6. Run the file
7. Copy the code of getDistance to another file and save it with name distance.py
8. Create a new file named compute_distance.py in same directory
9. Import distance.py module by using following command
from distance import getDistance
10. Try use the command below and observe the results
If __name__ == ‘__main__’
Solution:
Here is the Call to the Function
Experiment # 2: Write a python program for estimating value of PI using monte-Carlo
Simulation.
Solution: