Skip to content
Middle School Python
NY-CSDF.6-8.CT.8

Write functions and debug explicit contracts

Write functions with parameters, return values, docstrings, and predictable outputs.

Learn the skill

  1. 1Write functions with parameters, return values, docstrings, and predictable outputs.
  2. 2Use dictionaries for lookup tables and debug with error messages plus print tracing.

Cited instruction

Use the publisher's material for instruction, then return to PeerTutor for the checked practice written for this skill.

Computer Science and Digital Fluency · New York State Education Department

Practice preview

What does clamp(12, 0, 10) return? def clamp(value, low, high): return max(low, min(value, high))

What does greet() return? def greet(name="student"): return "Hi, " + name

Which function is pure?

Open adaptive practice

Course mapping reviewed by Nikhil on 2026-08-26. Practice is authored for PeerTutor and does not reproduce linked providers' exercises.

Write functions and debug explicit contracts practice · PeerTutor