Question

In: Computer Science

PYTHON!!! Radioactive materials decay over time and turn into other substances. For example, the most common...

PYTHON!!!

Radioactive materials decay over time and turn into other substances. For example, the most common isotope of uranium, U-238, decays into thorium-234 by emitting an alpha-particle. The rate of radioactive decay of a material is measured in terms of its half-life. The half-life of a material is defined to be the amount of time it takes for half of the material to undergo radioactive decay. Let m be the initial mass in grams of some material and let h be the material’s half-life in days. Then the remaining mass of the material on day t, denoted m(t), is given by the formula: m(t) = m × 0.5 t/h

Note: This formula is not a Python assignment statement! It is an equation that says: if you know the quantities m, t, and h, you can calculate a value using the right side of the equation. That value will be the amount of remaining mass of the material after t days. For this question, write a program which does the following: • Prompt the user to enter the initial mass of the material (in grams). You must make sure that the user enters a positive number. If they do not enter a positive number, print a message informing them so, and prompt them to enter the initial amount of material again. Keep doing this until they enter a positive number. • Prompt the user to enter the half-life of the material (in days). As above, make sure that the user enters a positive number, and if they don’t, keep asking until they do. • Starting from day 0, output the amount of the material remaining at one-day intervals. Thus, for day 0, day 1, day 2, etc., you should print out the amount of remaining mass according to the above formula. Your program should stop on the first day on which remaining mass is less than 1% of the initial mass. Don’t forget to import the math module if you need math functions. Hint: A correct solution should make use of three while-loops.

Solutions

Expert Solution

Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change. 

Let me know for any help with any other questions.

Thank You!

===========================================================================

import math


def main():
    print('        *** Radioactive Decay Table ***')
    mass = 0
    while mass<=0:
        mass = float(input('Enter the intial mass of the material (in grams): '))
        if mass <= 0:
            print('Error: Mass cannot be zero or negative. Please re-enter.')

    half_life = 0
    while half_life<=0:
        half_life = float(input('Enter half-life of the material (in days): '))
        if half_life <= 0:
            print('Error: Half-Life cannot be zero or negative. Please re-enter.')

    print('{:<10}{:<20}'.format('Day#', 'Mass Remaining (in grams)'))
    day = 0
    initial_mass = mass
    while True:
        print('{:<10}{:^20.4f}'.format(day, mass))
        day += 1
        mass = mass * (0.5 ** (day / half_life))
        if (mass) / initial_mass < 0.01: break


if __name__ == '__main__':
    main()

==================================================================


Related Solutions

Radioactive Decay Objective: to study the radioactive decay of materials. Understand the  concept of half life and...
Radioactive Decay Objective: to study the radioactive decay of materials. Understand the  concept of half life and randomness of the radioactive decay Run the case of H3 decay to He3: Go to “Multiple Atoms” tab Start with 80 atoms by clicking on the bucket. Start running and record the time when the number of H3 is changing to 40, 20, 10, and 5.This is accumulative time Repeat the above step 5 times and average them (below is an example of table...
Derive the exponential expression that describes the radioactive decay in the number of nucleotides, N over...
Derive the exponential expression that describes the radioactive decay in the number of nucleotides, N over a time, t. Give an example of another physical phenomenon which is described by an exponential relationship such as this. b) A radioactive nucleotide has a half-life of 20.0 years. What fraction of an initially pure sample of this nuclide will remain at the end of (i) 50.0 years, and (ii) 100.0 years. c) Give an account of nuclear binding energy, accompanied by a...
The equation A = Ao * e^(-t(log2/h)) is used to model the decay of radioactive materials....
The equation A = Ao * e^(-t(log2/h)) is used to model the decay of radioactive materials. Where A is the amount of material at time t, A0 is the amount at time 0 and h is the half-life. Write a program that prompts for a decay time and how long of an interval you want to look at. Then write the code that creates a table with the appropriate information. For example, the decay rate is 6 months for material...
Radioactive Decays What are the three most common types of radioactive decays? How do they differ?...
Radioactive Decays What are the three most common types of radioactive decays? How do they differ? Also how many types of decays are there? Please describe them.
If a spill of radioactive material occurred over an aquifer, estimate the length of time required...
If a spill of radioactive material occurred over an aquifer, estimate the length of time required for the material to reach a river 2 mi away if the aquifer is a) Gravel b) Clay c) Sandstone d) Granite Groundwater elevation at the spill site is 100 ft above the water surface in the river.
Ice floats on water. For most other substances however, the solid sinks in the liquid.
 Ice floats on water. For most other substances however, the solid sinks in the liquid. Classify each of these statements as true for water, or true for most other substances.
Both bacteria and phagocytic cells create toxins or harmful substances to attack each other. In most...
Both bacteria and phagocytic cells create toxins or harmful substances to attack each other. In most cases, these substances could intoxify themselves in the process. How do bacteria prevent toxic effectors from targeting themselves and how do phagocytic cells prevent harmful substances from damaging themselves?
provide an example of the most common type of pay in companies.
provide an example of the most common type of pay in companies.
What are the most common alloying elements used in stainless steel materials? What are the effects...
What are the most common alloying elements used in stainless steel materials? What are the effects of each alloying elements on steel?
Questions a. The most common example of a market with perfect competition is agriculture. How could...
Questions a. The most common example of a market with perfect competition is agriculture. How could farm subsidies distort a model of perfect competition? Explain. b. American corn farmers receive billions of dollars in taxpayer subsidies each year. These subsidies allow them to sell their grain at prices below what it costs to produce it, particularly for export markets. How do U.S. corn subsidies hurt Mexican farmers? What could be done to address this problem, and why would the solution...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT