Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Purpose: To practice using loops to repeat actions until a condition is met (and solve a practical problem at the same time!). Degree of Difficulty:

Purpose: To practice using loops to repeat actions until a condition is met (and solve a practical problem at the same time!). Degree of Difficulty: Easy Radioactive materials decay over time and turn into other substances. For example, Carbon-14 decays into Nitrogen-14 through beta decay. 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 materials 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.5t/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 dont, 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. Dont forget to import the math module if you need any non-built-in Python math functions. Hint: You can use two separate while-loops to ensure that the user enters correct values for a) the initial mass and b) the half-life You can also use another while-loop to calculate and display the remaining mass on a daily basis.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

T Sql Window Functions For Data Analysis And Beyond

Authors: Itzik Ben Gan

2nd Edition

0135861446, 978-0135861448

More Books

Students also viewed these Databases questions