SlideShare a Scribd company logo
fromrandom importrandom
def play():
i=-1
p=0
while (p< 0.5):
i=i+1
p=random()
payoff=2**i
return(payoff)
a=range(1000000)
for i in range(1,1000000):
a[i]=play()
print(sum(a)/len(a))

More Related Content

What's hot

Cuarto Punto Parte A
Cuarto Punto Parte ACuarto Punto Parte A
Cuarto Punto Parte Agustavo206
 
Coordenadas jugador
Coordenadas jugadorCoordenadas jugador
Coordenadas jugadorOscar Torres
 
Python real time tutorial
Python real time tutorialPython real time tutorial
Python real time tutorial
Rajeev Kumar
 
Let's golang
Let's golangLet's golang
Let's golang
SuHyun Jeon
 
Performance Comparison JVM Languages
Performance Comparison JVM LanguagesPerformance Comparison JVM Languages
Performance Comparison JVM Languages
Corneil du Plessis
 
Bayesian workflow with PyMC3 and ArviZ
Bayesian workflow with PyMC3 and ArviZBayesian workflow with PyMC3 and ArviZ
Bayesian workflow with PyMC3 and ArviZ
Corrie Bartelheimer
 
Diagrama de flujo de simulacion de variables
Diagrama de flujo de simulacion de variablesDiagrama de flujo de simulacion de variables
Diagrama de flujo de simulacion de variables
ErickPea26
 
Program presentation
Program presentationProgram presentation
Program presentation
MdAlauddinRidoy
 
The Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorThe Moore-Spiegel Oscillator
The Moore-Spiegel Oscillator
Abhranil Das
 
ML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional LanguageML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional Languagelijx127
 
Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++
radar radius
 
Don’t care contion
Don’t care contionDon’t care contion
Don’t care contionVenkat Raman
 
Matlab code of chapter 4
Matlab code of chapter 4Matlab code of chapter 4
Matlab code of chapter 4Mohamed El Kiki
 
Concurrent Application Development using Scala
Concurrent Application Development using ScalaConcurrent Application Development using Scala
Concurrent Application Development using Scala
Siarhiej Siemianchuk
 

What's hot (18)

งาน 9
งาน 9งาน 9
งาน 9
 
Cuarto Punto Parte A
Cuarto Punto Parte ACuarto Punto Parte A
Cuarto Punto Parte A
 
Coordenadas jugador
Coordenadas jugadorCoordenadas jugador
Coordenadas jugador
 
Python real time tutorial
Python real time tutorialPython real time tutorial
Python real time tutorial
 
Let's golang
Let's golangLet's golang
Let's golang
 
Performance Comparison JVM Languages
Performance Comparison JVM LanguagesPerformance Comparison JVM Languages
Performance Comparison JVM Languages
 
Segundo Punto
Segundo PuntoSegundo Punto
Segundo Punto
 
Bayesian workflow with PyMC3 and ArviZ
Bayesian workflow with PyMC3 and ArviZBayesian workflow with PyMC3 and ArviZ
Bayesian workflow with PyMC3 and ArviZ
 
Diagrama de flujo de simulacion de variables
Diagrama de flujo de simulacion de variablesDiagrama de flujo de simulacion de variables
Diagrama de flujo de simulacion de variables
 
Day 3 examples
Day 3 examplesDay 3 examples
Day 3 examples
 
Program presentation
Program presentationProgram presentation
Program presentation
 
The Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorThe Moore-Spiegel Oscillator
The Moore-Spiegel Oscillator
 
ML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional LanguageML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional Language
 
Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++
 
Don’t care contion
Don’t care contionDon’t care contion
Don’t care contion
 
Matlab code of chapter 4
Matlab code of chapter 4Matlab code of chapter 4
Matlab code of chapter 4
 
Concurrent Application Development using Scala
Concurrent Application Development using ScalaConcurrent Application Development using Scala
Concurrent Application Development using Scala
 
งาน 9
งาน 9งาน 9
งาน 9
 

Python.St.Petersburg Paradox sim