[{"id":"pythonbeginner-001","courseId":"python-beginner","domain":"syntax-and-types","topic":"range() end value","prompt":"A script runs this loop in Python 3. Which numbers does it print?","hint":"Think about whether the second argument of range() is itself produced.","explain":"range() produces a sequence of whole numbers from a start value up to a stop value, and for loops are its usual use. Consider whether the stop value itself ever appears in what it makes.","source":"https://docs.python.org/3/tutorial/controlflow.html","interaction":{"type":"single"},"options":[{"id":"a","text":"1, 2, 3, 4","why":"range(1, 5) starts at 1 and stops before 5, so 5 is never produced."},{"id":"b","text":"1, 2, 3, 4, 5","whyNot":"The stop value is excluded; range() never includes its end point."},{"id":"c","text":"0, 1, 2, 3, 4","whyNot":"range() begins at the start value you pass, here 1, not at 0."},{"id":"d","text":"1, 2, 3","whyNot":"The sequence runs up to 4, not one short; only the stop value itself is left out."}],"answer":"a","explanation":"range(start, stop) generates start up to but not including stop. The stop value is never part of the sequence.","concept":"range(start, stop) generates start up to but not including stop. The stop value is never part of the sequence.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"for i in range(1, 5):\n    print(i)","takeaways":["range(a, b) stops just before b, so range(1, 5) gives 1 to 4."]},{"id":"pythonbeginner-002","courseId":"python-beginner","domain":"syntax-and-types","topic":"Strings are immutable","prompt":"A script runs this code in Python 3. What happens?","hint":"Think about whether a string can be changed after it is created.","explain":"Python's built-in types differ in whether their contents can be changed after creation. Reassigning a name and changing the value it points to are separate ideas.","source":"https://docs.python.org/3/tutorial/introduction.html","interaction":{"type":"single"},"options":[{"id":"a","text":"It raises TypeError: 'str' object does not support item assignment","why":"Strings are immutable, so one position in a string can't be assigned to."},{"id":"b","text":"word becomes 'Jython'","whyNot":"Strings can't be edited in place; a new string has to be built instead."},{"id":"c","text":"The assignment is silently ignored and word stays 'Python'","whyNot":"Python doesn't skip this assignment; it stops with a TypeError."},{"id":"d","text":"It raises IndexError because index 0 is read-only","whyNot":"Index 0 is valid for reading; the error comes from the string being immutable."}],"answer":"a","explanation":"str objects are immutable. Assigning to an index such as s[0] raises TypeError, and changing text means building a new string.","concept":"str objects are immutable. Assigning to an index such as s[0] raises TypeError, and changing text means building a new string.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"word = 'Python'\nword[0] = 'J'","takeaways":["Assigning to one position of a string raises TypeError, because strings are immutable."]},{"id":"pythonbeginner-003","courseId":"python-beginner","domain":"syntax-and-types","topic":"Truth value of built-in values","prompt":"Which TWO of these values are false when Python tests them as the condition of an if statement?","hint":"Consider which built-in values have no contents or represent no value at all.","explain":"Python decides whether a value counts as true or false when it is used as a condition. Most objects count as true by default, and only a short list of built-in values count as false.","source":"https://docs.python.org/3/library/stdtypes.html","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"None","why":"None is one of the constants Python defines as false."},{"id":"b","text":"[]","why":"An empty list is an empty collection, and empty collections are false."},{"id":"c","text":"'0'","whyNot":"A one-character string is not empty, so it is true whatever its character is."},{"id":"d","text":"(0,)","whyNot":"A tuple with one item is not empty, so it is true."},{"id":"e","text":"{0}","whyNot":"A set with one item is not empty, so it is true."},{"id":"f","text":"'False'","whyNot":"Any non-empty string is true, even one that spells out False."}],"answer":"ab","explanation":"Built-in false values are None, False, numeric zeros, and empty sequences and collections. Other objects are true by default.","concept":"Built-in false values are None, False, numeric zeros, and empty sequences and collections. Other objects are true by default.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Empty containers are false; a container with even one item is true."]},{"id":"pythonbeginner-004","courseId":"python-beginner","domain":"syntax-and-types","topic":"Division returns a float","prompt":"In Python 3, a script runs print(17 / 3). What does it print?","hint":"Plain division and floor division are different operators.","explain":"Python has separate division operators, and they return different kinds of results. Check what kind of number plain division produces in Python 3.","source":"https://docs.python.org/3/tutorial/introduction.html","interaction":{"type":"single"},"options":[{"id":"a","text":"5.666666666666667","why":"In Python 3, / always returns a float, so the result keeps the fraction."},{"id":"b","text":"5","whyNot":"That is what // gives; plain / keeps the fractional part."},{"id":"c","text":"6","whyNot":"Plain division doesn't round to a whole number; it returns the exact float."},{"id":"d","text":"5.67","whyNot":"The float is not cut to two decimal places; it holds full precision."}],"answer":"a","explanation":"The / operator always returns a float. The // operator is floor division, which discards the fraction.","concept":"The / operator always returns a float. The // operator is floor division, which discards the fraction.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"print(17 / 3)","takeaways":["/ always gives a float in Python 3; use // when you need a whole-number result."]},{"id":"pythonbeginner-005","courseId":"python-beginner","domain":"syntax-and-types","topic":"The pass statement","prompt":"In Python, the body of an if statement can be left empty, with only the if line and its colon, and the program still runs.","hint":"Think about what Python expects to find on the indented lines under a header.","explain":"Python marks a block of code by its indentation, and a header such as if or def introduces one. Consider what the indented part must contain, and what a placeholder is for when the real code isn't written yet.","source":"https://docs.python.org/3/tutorial/controlflow.html","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"Not so: the header needs an indented statement under it, so an empty body is a syntax error."},{"id":"b","text":"False","why":"A block must hold at least one statement, so an empty body is a syntax error. pass is a statement that does nothing, and it can fill that slot."}],"answer":"b","explanation":"A block after a header such as if or def must contain at least one statement. pass is a statement that does nothing, so it can fill an empty block.","concept":"A block after a header such as if or def must contain at least one statement. pass is a statement that does nothing, so it can fill an empty block.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["pass does nothing; it fills a block that needs a statement."]}]