{"id":"code-hs-python-range-practice-problems","audience":"high-school","category":"coding","track":"coding","technique":"examples","title":"Make range() practice problems that target off-by-one mistakes","free":false,"task":"You keep missing range() questions. Make exactly 3 numbered practice problems, each 'How many times does this print? `for i in range(...): print(i)`', where problem 1 uses range(stop), problem 2 range(start, stop) and problem 3 a negative step. Then a line 'Answers' and 3 numbered answers that list the values of i and then the count, like '[2, 3, 4] - 3 times'. No code blocks, under 100 words.","materialLabel":"Your class notes and quiz mistakes (attached to your prompt automatically)","material":"Intro to Python - for loops and range() (Ms. Abara)\n\nrange(stop)            -> 0, 1, 2, ... stop - 1\nrange(start, stop)     -> start, start + 1, ... stop - 1\nrange(start, stop, step)\n   step can be negative: range(5, 0, -1) -> 5, 4, 3, 2, 1\n   the stop number is NEVER included\n\nfor i in range(3):\n    print(i)        # prints 0, 1, 2  (3 times)\n\nMy quiz mistakes (got 6/10):\n - said range(4) prints 1, 2, 3, 4   (wrong: starts at 0)\n - said range(2, 6) runs 5 times     (wrong: 4 times)\n - said range(10, 0, -2) includes 0  (wrong: stop is never included)\n\nUnit test is next Wednesday. Ms. Abara said there will be\n\"a few what-does-this-print questions and one with a negative step\".\n\nOther stuff in the unit we already did fine on:\n - while loops\n - break and continue","rules":[{"type":"questionCount","count":3},{"type":"codeBlocks","count":0},{"type":"maxProseWords","max":100}],"mistakes":[{"title":"Random topics","why":"The AI mixes in while loops and break, which you already know.","fix":"Say: \"Only range() problems: one with one number, one with start and stop, one with a negative step.\"","checks":["r1"]},{"title":"Different question styles","why":"The AI writes 'write a loop that...' problems that don't match the test.","fix":"Show it: \"How many times does this print? `for i in range(2, 5): print(i)`\".","checks":["r0"]},{"title":"Answers without the values","why":"A bare number doesn't show you where you went off by one.","fix":"Ask: \"List the values of i, then the count, like [2, 3, 4] - 3 times.\"","checks":["r2"]},{"title":"Too many, or with code blocks","why":"The AI writes 10 problems with code blocks and explanations.","fix":"Add: \"Exactly 3 numbered problems, then a line 'Answers'. No code blocks.\"","checks":["questionCount","codeBlocks","maxProseWords"]}],"promptHints":[{"label":"Sets the number of problems","patterns":["\\b(3|three)\\b.{0,20}(problem|question)"]},{"label":"Shows the problem shape","patterns":["how many times","print\\(i\\)","backtick"]},{"label":"Covers the three forms","patterns":["negative step","start, stop","one number"]},{"label":"Asks for worked answers","patterns":["values of i","\\[\\d","list the values"]},{"label":"Separates the answers","patterns":["answers","at the end"]}],"hint":"Practice works best when it hits your exact mistakes in the test's format. Tell the AI which forms of range(), the question shape and how to show the answers.","rubricLabels":["Every problem is written as 'How many times does this print?' with a one-line for i in range(...): print(i) snippet in backticks","Problem 1 uses range with one number, problem 2 uses range(start, stop) and problem 3 uses a negative step","After a line 'Answers', each of the 3 answers lists the values of i in brackets and then the count (like '[2, 3, 4] - 3 times'), and every answer is correct (the stop value is never included)"]}