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. /The kin and flock calculator
BiologyHardHigh School (11–12)Animal Behaviour and Ethology

The kin and flock calculator

You will work out the relatedness of worker bees, test Hamilton's rule, and find how safe a flock is.

The idea. Two workers whose mother mated with nnn males have an average relatedness of 0.25+0.5/n0.25 + 0.5/n0.25+0.5/n. Helping is favoured when rB>CrB > CrB>C. In a flock of nnn birds, each alert with chance ppp, the chance that at least one is alert is 1−(1−p)n1 - (1 - p)^n1−(1−p)n.

Your tasks.

  1. Finish sister_r. It gives the average relatedness of two workers for a number of fathers.
  2. Finish helps. It gives True when Hamilton's rule favours helping.
  3. Finish alert. It gives the chance that at least one bird of a flock is alert.

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 smallest flock with alert(0.1, n) above 0.9. How many birds is that?

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
← The dance decoderThe forager's calculator →
More onAnimal Behaviour and Ethology

Discussion (0)

Log in to join the discussion.

Loading…

More labs on this topic

  1. The migrant's plannerHard
  2. The forager's calculatorHard
  3. The dance decoderHard
  4. The learning curve labHard
  5. The choice chamber checkerHard
All labs on this topic →