In: Computer Science
Write a python programme in a Jupyter notebook which asks the user to input the number of radioactive nuclei in a sample, the number at a later time, and the elapsed time. The programme should calculate and display the decay constant and the half-life. The decay is described by the equations:
? = ? ?−?? ?0
?1/2 = ln (2)
.
Test your programme a sample that contains 4.00x108 nuclei initially and 1.57x107 nuclei after 150 seconds.
SO THEREFORE A PROGRAM THAT WILL ENABLE ME TO INPUT THE ABOVE VALUE TO TEST IT. THANKS
Python code for the problem using Jupyter notebook is provided, please comment if any doubts:
Note: The screen shot of the code and output provided at the end. note that the inputs are inputted in scientific notation, using "e" for the powers of 10. You can input as whole numbers also.
Python code:
#import the math package
import math
#take the inputs
N0=float(input("Enter the number of radioactive nuclei in a sample:
"))
N=float(input("Enter the number of radioactive nuclei at later
time,: "))
t=float(input("Enterthe elapsed time: "))
#compute e^-lamda t
lt=N/N0
#compute lamda
lamda= -1* math.log(lt)/t
#compute half time
t12=math.log(2)/lamda
#print the results
print('The decay constant= ', lamda)
print('The half time= ', t12)
Output:
Screenshot of the Jupyter notebook :