seed: curriculum content

This commit is contained in:
2026-05-07 14:32:44 +00:00
parent 9258534803
commit ec76f4f56b
100 changed files with 2846 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
---
type: challenge
title: "The Validator"
xp: 75
duration: 30
difficulty: 2
---
# The Validator
> **[INCOMING — Mission Control, Earth]**
>
> Cadet, every system that takes user input has to *validate* it.
>
> Comparison operators (`>=`, `<`, `==`) return `True` or `False`
> directly. String methods like `.isupper()` and `.isdigit()` also
> return booleans:
>
> ```python
> len("hello") >= 8 # False
> "Hello"[0].isupper() # True
> "abc1"[-1].isdigit() # True
> ```
>
> Implement `validate(pw)` that returns a dict with four checks on
> a non-empty password:
>
> - `length` — char count (int)
> - `long_enough` — `length >= 8` (bool)
> - `starts_capital` — first char uppercase (bool)
> - `ends_digit` — last char a digit (bool)
>
> [END TRANSMISSION]
## Your Task
In `starter/starter.py`, return the dict using `len()`, `>=`,
`.isupper()`, `.isdigit()`.
## Objectives
- All four keys present with correct types
- `validate("Andromeda1")` matches the expected dict exactly
- Works for any non-empty password

View File

@@ -0,0 +1,17 @@
def validate(pw):
"""Check four properties of a non-empty password and return a dict.
Keys:
"length" — number of characters (int)
"long_enough" — True if length >= 8 (bool)
"starts_capital" — True if first char is uppercase (bool)
"ends_digit" — True if last char is a digit (bool)
Helpers:
pw[0].isupper() — True if first char is uppercase
pw[-1].isdigit() — True if last char is a digit
validate("Andromeda1") -> {"length": 10, "long_enough": True,
"starts_capital": True, "ends_digit": True}
"""
pass

View File

@@ -0,0 +1,41 @@
from solution import validate
def test_strong_password():
r = validate("Andromeda1")
assert r == {
"length": 10,
"long_enough": True,
"starts_capital": True,
"ends_digit": True,
}
def test_short_lowercase_no_digit():
r = validate("abc")
assert r == {
"length": 3,
"long_enough": False,
"starts_capital": False,
"ends_digit": False,
}
def test_capital_no_digit():
r = validate("Hello")
assert r == {
"length": 5,
"long_enough": False,
"starts_capital": True,
"ends_digit": False,
}
def test_long_lowercase_with_digit():
r = validate("spaceX2026")
assert r == {
"length": 10,
"long_enough": True,
"starts_capital": False,
"ends_digit": True,
}