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. /Validation checks before a record is stored
Computer ScienceEasyHigh School (9–10)Computer Science › Databases and SQL

Validation checks before a record is stored

A school stores its lockers in a table. You will write three validation checks and use them to decide which typed records go into the table.

Your tasks.

  1. length_check(code): return True only if the locker code has exactly 444 characters.
  2. range_check(floor): return True only if the floor is from 000 to 333, including both ends.
  3. presence_check(name): return True only if the name is not empty.

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, add a format check: the code is the letter L followed by three digits. Which typed record does it reject?

StemPy LabContributed by StemPy Lab
python
Loading Python runtime…

A 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
← Build a table with a primary keyChoosing records with WHERE →
More onComputer Science › Databases and SQL

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Validation in a database tableDatabase Tables, Data Types and Primary Keys

More labs on this topic

  1. Two conditions with AND and OREasy
  2. Counting and adding up salesEasy
  3. Sorting with ORDER BYEasy
  4. Choosing records with WHEREEasy
Build a table with a primary keyEasy
All labs on this topic →