HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Python Labs
  2. /Attenuation in code
PhysicsEasyHigh School (11–12)Medical Physics

Attenuation in code

You will write three functions that a radiographer uses to plan shielding and filters.

The idea. A beam falls off as I=I0e−μxI = I_0e^{-\mu x}I=I0​e−μx. The half-value thickness is ln⁡2/μ\ln 2/\muln2/μ. The thickness that lets a share sss through is ln⁡(1/s)/μ\ln(1/s)/\muln(1/s)/μ.

Your tasks.

  1. In transmitted, return the intensity after a thickness x, for a starting intensity i0 and a coefficient mu.
  2. In half_value, return the half-value thickness.
  3. In thickness_for, return the thickness that lets the share share through, for example 0.01 for 1 %1\ \%1 %.

Run it first, just as it is. The checker at the end prints FAIL for each task. Then do the tasks one at a time, and run the program again after each one. A Hint appears under every check that still fails.

When every line says PASS, find the thickness of lead with mu = 45.2 per centimetre that lets one photon in a thousand through.

StemPy LabContributed by StemPy Lab
python
Loading Python runtime…

A worked solution

Run your code once to unlock the worked solution.

Have you tried it?

Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.

Log in to save
← All Labs
← Depth, fading and blood flow in codeCT numbers and MRI frequencies in code →
More onMedical Physics

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Attenuation, contrast and the X-ray imageX-Ray Imaging, CT and MRI

More labs on this topic

  1. Dose in codeMedium
  2. Tracer arithmetic in codeEasy
  3. CT numbers and MRI frequencies in codeMedium
  4. Depth, fading and blood flow in codeMedium
Impedance and echoes in codeEasy
All labs on this topic →