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 →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • 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. /Formulas from voids
ChemistryMediumHigh School (11–12)Solid State

Formulas from voids

You will write functions that turn a description of voids into a formula. One finds the size of each void. One counts the cations for each anion. One writes the formula in the smallest whole numbers. One checks the charges.

The idea. NNN close packed anions make NNN octahedral and 2N2N2N tetrahedral voids. A tetrahedral void takes a sphere of (1.5−1)R(\sqrt{1.5} - 1)R(1.5​−1)R and an octahedral void (2−1)R(\sqrt{2} - 1)R(2​−1)R. Exact fractions keep the formula exact: Python's Fraction(2, 3) is two thirds.

Your tasks.

  1. Complete void_radius(kind, R) for "tet" and "oct".
  2. Complete cations_per_anion(tet, oct), where tet and oct are the fractions of the voids that are filled.
  3. Complete formula(tet, oct) so that it returns the smallest whole numbers (cations, anions).
  4. Complete neutral(cation_charge, anion_charge, tet, oct) so that it returns True when the charges balance.

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 formula when cations fill a quarter of the tetrahedral voids and a quarter of the octahedral voids.

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
← A cubic cell calculatorIonic structures from their radii →
More onSolid State

Discussion (0)

Log in to join the discussion.

Loading…

More labs on this topic

  1. An indexing machineHard
  2. A Bragg's law toolkitMedium
  3. A defect calculatorMedium
  4. Ionic structures from their radiiMedium
  5. A cubic cell calculatorMedium
All labs on this topic →