SlideShare a Scribd company logo
Use Python Code to add a block of code to count the number of dots within the red circle on the
graph that is produced.
import sys
import numpy as np # an alias for the namespace
import random
import matplotlib.pyplot as plt
#setting MC parameters
NumP=10000 # generate how many random point in side the square
n=100
#MC simulation block
pi_all=[]
#
for j in range(n):
cordx=[];cordy=[] # initialize the two empty coordinate lists
inside=0
for i in range(0,NumP): #generate random coordinates
cordx.append(random.random())
cordy.append(random.random())
r2 = cordx[i]*cordx[i]+cordy[i]*cordy[i]
if r2 <= 1:
inside=inside+1
# write control to count inside
pit= 4.0*inside/NumP
#End of sampling
pi_all.append(pit)
#print out result
print("pi: ","{:10.6f}".format(pit))
plt.hist(pi_all) # print hist of the sampling
# plot the random pair: cordx,cordy graphically for the last MC simulation
Symbol=10
LineW = 3
Lsp=100
f = plt.figure()
f.set_figwidth(8)
f.set_figheight(8)
plt.xlim(0,1)
plt.ylim(0,1)
plt.xlabel('X Cordinate')
plt.ylabel('Y Cordinate')
plt.scatter(cordx, cordy, s=Symbol,marker='o')
#plot circle
x = np.linspace(0,1,Lsp)
y = np.sqrt(1. - x*x)
plt.plot(x, y,'-r',color='red', linestyle='-', lw=LineW)
plt.show()
Use Python Code to add a block of code to count the number of dots wit.pdf

More Related Content

Similar to Use Python Code to add a block of code to count the number of dots wit.pdf

Class 8b: Numpy & Matplotlib
Class 8b: Numpy & MatplotlibClass 8b: Numpy & Matplotlib
Class 8b: Numpy & Matplotlib
Marc Gouw
 
C++ file
C++ fileC++ file
Write code in c++ Program to a topological sort on a graph Program pl.docx
Write code in c++ Program to a topological sort on a graph  Program pl.docxWrite code in c++ Program to a topological sort on a graph  Program pl.docx
Write code in c++ Program to a topological sort on a graph Program pl.docx
noreendchesterton753
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
Saket Pathak
 
Modify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfModify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdf
mallik3000
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdf
giriraj65
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
eugeniadean34240
 
PYTHON_PROGRAM(1-34).pdf
PYTHON_PROGRAM(1-34).pdfPYTHON_PROGRAM(1-34).pdf
PYTHON_PROGRAM(1-34).pdf
Neeraj381934
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...
Andrey Karpov
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
C++ Homework Help
 
c plus plus programsSlide
c plus plus programsSlidec plus plus programsSlide
c plus plus programsSlide
harman kaur
 
matplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guidematplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guideArulalan T
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
HIMANSUKUMAR12
 
PRACTICAL FILE(COMP SC).pptx
PRACTICAL FILE(COMP SC).pptxPRACTICAL FILE(COMP SC).pptx
PRACTICAL FILE(COMP SC).pptx
AbhinavGupta257043
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ code
PVS-Studio LLC
 
SCIPY-SYMPY.pdf
SCIPY-SYMPY.pdfSCIPY-SYMPY.pdf
SCIPY-SYMPY.pdf
FreddyGuzman19
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
Andrey Karpov
 
Matlab project
Matlab projectMatlab project
Matlab project
iftikhar ali
 
Write an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdfWrite an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdf
aaryanentp
 

Similar to Use Python Code to add a block of code to count the number of dots wit.pdf (20)

Class 8b: Numpy & Matplotlib
Class 8b: Numpy & MatplotlibClass 8b: Numpy & Matplotlib
Class 8b: Numpy & Matplotlib
 
C++ file
C++ fileC++ file
C++ file
 
Write code in c++ Program to a topological sort on a graph Program pl.docx
Write code in c++ Program to a topological sort on a graph  Program pl.docxWrite code in c++ Program to a topological sort on a graph  Program pl.docx
Write code in c++ Program to a topological sort on a graph Program pl.docx
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
 
Modify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfModify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdf
 
Using an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdfUsing an Array include ltstdiohgt include ltmpih.pdf
Using an Array include ltstdiohgt include ltmpih.pdf
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
 
PYTHON_PROGRAM(1-34).pdf
PYTHON_PROGRAM(1-34).pdfPYTHON_PROGRAM(1-34).pdf
PYTHON_PROGRAM(1-34).pdf
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
c plus plus programsSlide
c plus plus programsSlidec plus plus programsSlide
c plus plus programsSlide
 
matplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guidematplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guide
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
 
PRACTICAL FILE(COMP SC).pptx
PRACTICAL FILE(COMP SC).pptxPRACTICAL FILE(COMP SC).pptx
PRACTICAL FILE(COMP SC).pptx
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ code
 
SCIPY-SYMPY.pdf
SCIPY-SYMPY.pdfSCIPY-SYMPY.pdf
SCIPY-SYMPY.pdf
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
 
Matlab project
Matlab projectMatlab project
Matlab project
 
Write an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdfWrite an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdf
 

More from aonetechcomputers

Use modular arithmetic operations to computer 1210mod7- Show and uploa.pdf
Use modular arithmetic operations to computer 1210mod7- Show and uploa.pdfUse modular arithmetic operations to computer 1210mod7- Show and uploa.pdf
Use modular arithmetic operations to computer 1210mod7- Show and uploa.pdf
aonetechcomputers
 
Use K-maps to find MSOP and MPOS expressions for the following incompl.pdf
Use K-maps to find MSOP and MPOS expressions for the following incompl.pdfUse K-maps to find MSOP and MPOS expressions for the following incompl.pdf
Use K-maps to find MSOP and MPOS expressions for the following incompl.pdf
aonetechcomputers
 
Use Java to implement bottom-up LR parser for the following grammar an.pdf
Use Java to implement bottom-up LR parser for the following grammar an.pdfUse Java to implement bottom-up LR parser for the following grammar an.pdf
Use Java to implement bottom-up LR parser for the following grammar an.pdf
aonetechcomputers
 
Use C program and please do not use outside c99 mode Write a C program.pdf
Use C program and please do not use outside c99 mode Write a C program.pdfUse C program and please do not use outside c99 mode Write a C program.pdf
Use C program and please do not use outside c99 mode Write a C program.pdf
aonetechcomputers
 
Use Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdf
Use Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdfUse Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdf
Use Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdf
aonetechcomputers
 
Use any one of the previous homework assignments in which you created.pdf
Use any one of the previous homework assignments in which you created.pdfUse any one of the previous homework assignments in which you created.pdf
Use any one of the previous homework assignments in which you created.pdf
aonetechcomputers
 
Use a for loop Write a Python function that does the following- 1- Its.pdf
Use a for loop Write a Python function that does the following- 1- Its.pdfUse a for loop Write a Python function that does the following- 1- Its.pdf
Use a for loop Write a Python function that does the following- 1- Its.pdf
aonetechcomputers
 
Use an array and two index variables- Write functions or methods push (1).pdf
Use an array and two index variables-  Write functions or methods push (1).pdfUse an array and two index variables-  Write functions or methods push (1).pdf
Use an array and two index variables- Write functions or methods push (1).pdf
aonetechcomputers
 
Use a combination of information learned from chapters 3-5 and what yo.pdf
Use a combination of information learned from chapters 3-5 and what yo.pdfUse a combination of information learned from chapters 3-5 and what yo.pdf
Use a combination of information learned from chapters 3-5 and what yo.pdf
aonetechcomputers
 
us4 foday reports that about 25- of ah peison parofes become repeat of.pdf
us4 foday reports that about 25- of ah peison parofes become repeat of.pdfus4 foday reports that about 25- of ah peison parofes become repeat of.pdf
us4 foday reports that about 25- of ah peison parofes become repeat of.pdf
aonetechcomputers
 
Use the following sentence to match the phrase on the left to the most.pdf
Use the following sentence to match the phrase on the left to the most.pdfUse the following sentence to match the phrase on the left to the most.pdf
Use the following sentence to match the phrase on the left to the most.pdf
aonetechcomputers
 
Use the following image to answer the questions below- You have discov.pdf
Use the following image to answer the questions below- You have discov.pdfUse the following image to answer the questions below- You have discov.pdf
Use the following image to answer the questions below- You have discov.pdf
aonetechcomputers
 
Use Exoels function options to find the following z values for the sta.pdf
Use Exoels function options to find the following z values for the sta.pdfUse Exoels function options to find the following z values for the sta.pdf
Use Exoels function options to find the following z values for the sta.pdf
aonetechcomputers
 
Use the Dividend Growth Model to determine the expected annual growth.pdf
Use the Dividend Growth Model to determine the expected annual growth.pdfUse the Dividend Growth Model to determine the expected annual growth.pdf
Use the Dividend Growth Model to determine the expected annual growth.pdf
aonetechcomputers
 
Use the definition of O to show that n2+5nO(n2) (1).pdf
Use the definition of O to show that n2+5nO(n2) (1).pdfUse the definition of O to show that n2+5nO(n2) (1).pdf
Use the definition of O to show that n2+5nO(n2) (1).pdf
aonetechcomputers
 
Use the dataset below to calculate the Q1-.pdf
Use the dataset below to calculate the Q1-.pdfUse the dataset below to calculate the Q1-.pdf
Use the dataset below to calculate the Q1-.pdf
aonetechcomputers
 
use C++ with QT The Memento pattern is used for capturing and externa.pdf
use C++  with QT The Memento pattern is used for capturing and externa.pdfuse C++  with QT The Memento pattern is used for capturing and externa.pdf
use C++ with QT The Memento pattern is used for capturing and externa.pdf
aonetechcomputers
 
use any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdf
use any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdfuse any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdf
use any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdf
aonetechcomputers
 
Use the COUNTIF function to construct frequency distributions for gend (1).pdf
Use the COUNTIF function to construct frequency distributions for gend (1).pdfUse the COUNTIF function to construct frequency distributions for gend (1).pdf
Use the COUNTIF function to construct frequency distributions for gend (1).pdf
aonetechcomputers
 
Use the cladogram to answer the following questions- 11-) Is a bony sk.pdf
Use the cladogram to answer the following questions- 11-) Is a bony sk.pdfUse the cladogram to answer the following questions- 11-) Is a bony sk.pdf
Use the cladogram to answer the following questions- 11-) Is a bony sk.pdf
aonetechcomputers
 

More from aonetechcomputers (20)

Use modular arithmetic operations to computer 1210mod7- Show and uploa.pdf
Use modular arithmetic operations to computer 1210mod7- Show and uploa.pdfUse modular arithmetic operations to computer 1210mod7- Show and uploa.pdf
Use modular arithmetic operations to computer 1210mod7- Show and uploa.pdf
 
Use K-maps to find MSOP and MPOS expressions for the following incompl.pdf
Use K-maps to find MSOP and MPOS expressions for the following incompl.pdfUse K-maps to find MSOP and MPOS expressions for the following incompl.pdf
Use K-maps to find MSOP and MPOS expressions for the following incompl.pdf
 
Use Java to implement bottom-up LR parser for the following grammar an.pdf
Use Java to implement bottom-up LR parser for the following grammar an.pdfUse Java to implement bottom-up LR parser for the following grammar an.pdf
Use Java to implement bottom-up LR parser for the following grammar an.pdf
 
Use C program and please do not use outside c99 mode Write a C program.pdf
Use C program and please do not use outside c99 mode Write a C program.pdfUse C program and please do not use outside c99 mode Write a C program.pdf
Use C program and please do not use outside c99 mode Write a C program.pdf
 
Use Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdf
Use Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdfUse Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdf
Use Chapter 17 Problem 42 on Page 852 To prepare the following- 1- Pre.pdf
 
Use any one of the previous homework assignments in which you created.pdf
Use any one of the previous homework assignments in which you created.pdfUse any one of the previous homework assignments in which you created.pdf
Use any one of the previous homework assignments in which you created.pdf
 
Use a for loop Write a Python function that does the following- 1- Its.pdf
Use a for loop Write a Python function that does the following- 1- Its.pdfUse a for loop Write a Python function that does the following- 1- Its.pdf
Use a for loop Write a Python function that does the following- 1- Its.pdf
 
Use an array and two index variables- Write functions or methods push (1).pdf
Use an array and two index variables-  Write functions or methods push (1).pdfUse an array and two index variables-  Write functions or methods push (1).pdf
Use an array and two index variables- Write functions or methods push (1).pdf
 
Use a combination of information learned from chapters 3-5 and what yo.pdf
Use a combination of information learned from chapters 3-5 and what yo.pdfUse a combination of information learned from chapters 3-5 and what yo.pdf
Use a combination of information learned from chapters 3-5 and what yo.pdf
 
us4 foday reports that about 25- of ah peison parofes become repeat of.pdf
us4 foday reports that about 25- of ah peison parofes become repeat of.pdfus4 foday reports that about 25- of ah peison parofes become repeat of.pdf
us4 foday reports that about 25- of ah peison parofes become repeat of.pdf
 
Use the following sentence to match the phrase on the left to the most.pdf
Use the following sentence to match the phrase on the left to the most.pdfUse the following sentence to match the phrase on the left to the most.pdf
Use the following sentence to match the phrase on the left to the most.pdf
 
Use the following image to answer the questions below- You have discov.pdf
Use the following image to answer the questions below- You have discov.pdfUse the following image to answer the questions below- You have discov.pdf
Use the following image to answer the questions below- You have discov.pdf
 
Use Exoels function options to find the following z values for the sta.pdf
Use Exoels function options to find the following z values for the sta.pdfUse Exoels function options to find the following z values for the sta.pdf
Use Exoels function options to find the following z values for the sta.pdf
 
Use the Dividend Growth Model to determine the expected annual growth.pdf
Use the Dividend Growth Model to determine the expected annual growth.pdfUse the Dividend Growth Model to determine the expected annual growth.pdf
Use the Dividend Growth Model to determine the expected annual growth.pdf
 
Use the definition of O to show that n2+5nO(n2) (1).pdf
Use the definition of O to show that n2+5nO(n2) (1).pdfUse the definition of O to show that n2+5nO(n2) (1).pdf
Use the definition of O to show that n2+5nO(n2) (1).pdf
 
Use the dataset below to calculate the Q1-.pdf
Use the dataset below to calculate the Q1-.pdfUse the dataset below to calculate the Q1-.pdf
Use the dataset below to calculate the Q1-.pdf
 
use C++ with QT The Memento pattern is used for capturing and externa.pdf
use C++  with QT The Memento pattern is used for capturing and externa.pdfuse C++  with QT The Memento pattern is used for capturing and externa.pdf
use C++ with QT The Memento pattern is used for capturing and externa.pdf
 
use any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdf
use any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdfuse any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdf
use any photo Latest Club Activities Robo-Vision- Giving your robot ey.pdf
 
Use the COUNTIF function to construct frequency distributions for gend (1).pdf
Use the COUNTIF function to construct frequency distributions for gend (1).pdfUse the COUNTIF function to construct frequency distributions for gend (1).pdf
Use the COUNTIF function to construct frequency distributions for gend (1).pdf
 
Use the cladogram to answer the following questions- 11-) Is a bony sk.pdf
Use the cladogram to answer the following questions- 11-) Is a bony sk.pdfUse the cladogram to answer the following questions- 11-) Is a bony sk.pdf
Use the cladogram to answer the following questions- 11-) Is a bony sk.pdf
 

Recently uploaded

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 

Recently uploaded (20)

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 

Use Python Code to add a block of code to count the number of dots wit.pdf

  • 1. Use Python Code to add a block of code to count the number of dots within the red circle on the graph that is produced. import sys import numpy as np # an alias for the namespace import random import matplotlib.pyplot as plt #setting MC parameters NumP=10000 # generate how many random point in side the square n=100 #MC simulation block pi_all=[] # for j in range(n): cordx=[];cordy=[] # initialize the two empty coordinate lists inside=0 for i in range(0,NumP): #generate random coordinates cordx.append(random.random()) cordy.append(random.random()) r2 = cordx[i]*cordx[i]+cordy[i]*cordy[i] if r2 <= 1: inside=inside+1 # write control to count inside pit= 4.0*inside/NumP #End of sampling
  • 2. pi_all.append(pit) #print out result print("pi: ","{:10.6f}".format(pit)) plt.hist(pi_all) # print hist of the sampling # plot the random pair: cordx,cordy graphically for the last MC simulation Symbol=10 LineW = 3 Lsp=100 f = plt.figure() f.set_figwidth(8) f.set_figheight(8) plt.xlim(0,1) plt.ylim(0,1) plt.xlabel('X Cordinate') plt.ylabel('Y Cordinate') plt.scatter(cordx, cordy, s=Symbol,marker='o') #plot circle x = np.linspace(0,1,Lsp) y = np.sqrt(1. - x*x) plt.plot(x, y,'-r',color='red', linestyle='-', lw=LineW) plt.show()