Question: Q 2 . Create a NEW file with the name part 2 . Copy the content of the source file in Q 1 to

Q2. Create a NEW file with the name "part2". Copy the content of the source file in Q1 to this file. Modify the program developed for Q1 to perform the following tasks:
- Rewrite the function userMenu() such that if the user enters '\( r \)'(or 'R'), it will display "Please enter initial particles (\(\mathrm{N} O \)) : " on the screen. The user should input a positive value of type float and you should create a function inputVal () to handle this. Then, userMenu() will display "Please enter decay constant (lambda): " on the screen. The user should input a positive value of type float and the function inputVal () should be used. Then, userMenu () should call a function remainPart () which uses the values of \( N_{0}\) and \(\lambda \) as input parameters. Function remainPart() will display "Please enter time ( t ): " on the screen. The user should input a positive value of type float and the function inputVal () should be used. Function remainpart () will then display the number of remaining particles (an integer int) using equation (1) and the percentage to 3 decimal places. You may use \(\exp (\)) function in the math module. The function remainPart () should have no returned value.
- Rewrite the function userMenu() such that if the user enters '\( h \)'(or 'H'), it will display "Please enter decay constant (lambda): " on the screen. The user should input a positive value of type float and the function inputval () should be used. Then, userMenu () should call a function halflife () which uses the value of \(\lambda \) as input parameter. Function halflife() will compute and display the half-life of the element by solving equation (1). Note that the half-life of an element is the time taken so that the number of remaining particles is exactly half the original number, i.e., it is the time taken for 5000 particles to decay out of \( N_{0}\)\(=10000\) particles. You may use \(\log (\)) function in the math module. The function halflife () should have no returned value. Print the two float outputs to 3 decimal places, assuming that 1 year \(=365.2422\) days.
- Rewrite the function userMenu () such that if the user enters '1'(or '\('\)'), it will make use of inputval () to get a positive value for \(\lambda \), instead of asking and checking until getting a positive value as in Q1.
- The sample outputs given below should be realised by your program on executing it inside Jupyter Notebook or under any standard well-known Python platform. Notice that the character(s) following a '\( : \)' is/are entered by the user.
```
[1] Find mean lifetime
[r] Find remaining particles
[h] Find half-1ife
[f] Find best fitting curve from data
[q] Quit
Please enter your choice (1, r, h, f or q
to quit): r
Please enter initial particles (N0): -10
Input should be positive, please try
again: 0
Input should be positive, please try
again: 10000
Please enter decay constant (lambda): 0.6
Please enter time (}t\mathrm{): 2
Remaining particles after 2.000 years is
3012(30.119%)
[1] Find mean lifetime
[r] Find remaining particles
[h] Find half-life
[f] Find best fitting curve from data
[q] Quit
Please enter your choice (1, r, h, f or q
to quit): H
Please enter decay constant (lambda): 0
Input should be positive, please try
again: 0.4
Half-life is 1.733 years (632.917 days)
```
```
[1] Find mean lifetime
[r] Find remaining particles
[h] Find half-life
[f] Find best fitting curve from data
[q] Quit
Please enter your choice (1, r, h, f or q
to quit): q
Thank you for using our system!
```
Q 2 . Create a NEW file with the name "part 2 " .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!