Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
← CoursesFastAPI ProductionModule 1 · FastAPI BasicsPydantic v2 — your contract layerpredict3 / 105
+75 XP
Task
📝 **Predict** the result: ```python from pydantic import BaseModel, Field class Order(BaseModel): qty: int = Field(..., gt=0) try: Order(qty=-3) except Exception as e: print("error" if "greater" in str(e).lower() else "ok") ```
Predict the output

Read the code carefully

from pydantic import BaseModel, Field

class Order(BaseModel):
    qty: int = Field(..., gt=0)

try:
    Order(qty=-3)
except Exception as e:
    print("error" if "greater" in str(e).lower() else "ok")

What will the program print? Write here:

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…