aiskillstore/marketplace / skills/92bilal26/quiz-generator
quiz-generator
VerifiedGenerate 50-question interactive quizzes using the Quiz component with randomized batching. Use when creating end-of-chapter assessments. Displays 15-20 questions per session with immediate feedback. NOT for static markdown quizzes.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 6.1 KB |
| references/answer-distribution.md | markdown | 8.0 KB |
| references/bias-detection-checklist.md | markdown | 10.7 KB |
| references/example-quiz.md | markdown | 9.7 KB |
| references/file-naming.md | markdown | 7.3 KB |
| references/generation-process.md | markdown | 12.5 KB |
| references/option-length-validation.md | markdown | 10.8 KB |
| references/pitfalls-and-solutions.md | markdown | 19.9 KB |
| references/quality-checklist.md | markdown | 16.9 KB |
| scripts/redistribute_answers.py | script | 7.7 KB |
| scripts/redistribute_answers_v2.py | script | 16.2 KB |
| skill-report.json | config | 54.7 KB |
references/example-quiz.md
View on GitHub---
sidebar_position: 3
title: "Chapter 2: Variables and Data Types - Quiz"
---
# Chapter 2: Variables and Data Types - Quiz
Test your understanding of Python variables and data types. This quiz focuses on conceptual understanding through realistic scenarios.
<Quiz
title="Chapter 2: Variables and Data Types Assessment"
questions={[
{
question: "You create a variable x = [1, 2, 3] and later assign it to another variable y = x. Then you use y.append(4). Why does x also show [1, 2, 3, 4]?",
options: [
"Python automatically syncs all variables with the same data",
"The append() method creates a copy for both variables",
"Both x and y point to the same list object in memory",
"Lists in Python are always shared between assignments"
],
correctOption: 2,
explanation: "This is correct because lists are mutable objects passed by reference. When you assign y = x, both variables point to the SAME list object in memory, not separate copies. Modifying the list through either variable affects the shared object. This is fundamentally different from immutable types like strings and integers, where assignment creates separate bindings to the same value object. Understanding object references is critical for debugging unexpected variable changes and managing state in larger programs."
},
{
question: "A student writes: x = '5' + 5. They expect this to return '55' but get a TypeError. What concept is the student misunderstanding?",
options: [
"Python requires explicit type conversion between incompatible types",
"String concatenation should automatically convert numbers",
"The + operator works differently for strings and numbers",
"Type errors only occur with mathematical operations"
],
correctOption: 0,
explanation: "The correct answer highlights that Python is strongly typed and requires explicit conversion. The student expects implicit type coercion (automatic conversion), but Python demands you be explicit: either x = '5' + str(5) or x = int('5') + 5. Why the other answers are wrong: (1) String concatenation doesn't auto-convert—this is by design for safety; (2) The + operator IS different for strings (concatenates) vs. numbers (adds), but this isn't the core misconception; (3) Type errors occur in many contexts. This misconception stems from languages like JavaScript that do implicit type coercion. Understanding type safety prevents silent bugs where unintended conversions happen."
},
{
question: "After running: name = 'Alice'; name = 'Bob', which statement is true about memory?",
options: [
"'Alice' is deleted from memory because name no longer references it",
"Memory usage stays identical because strings are immutable",
"'Alice' is overwritten with 'Bob' in the same memory location",
"Both 'Alice' and 'Bob' remain in memory; name now points to 'Bob'"
],
correctOption: 3,
explanation: "This is correct because strings are immutable in Python. When you reassign name = 'Bob', the original 'Alice' string object remains in memory (until garbage collected when no references exist), while name now points to a new 'Bob' string object. Why the others are wrong: (1) 'Alice' isn't immediately deleted—Python uses garbage collection, not explicit deletion; (3) Strings aren't overwritten in place because they're immutable—a new object is created; (4) Memory usage actually increases slightly because both strings exist in memory. This illustrates the difference between mutable types (list, dict) where changes affect the original object, vs. immutable types (string, tuple, int) where 'changes' create new objects."
},
{
question: "You define age = 25. Later you use del age. What happens when you try to access age?",
options: [
"age returns None (the default value for undefined variables)",
"NameError is raised because age no longer exists in the namespace",
"age is set to 0 (the default for numeric types)",
"The previous value 25 is cached and returned"
],
correctOption: 1,
explanation: "The correct answer is NameError because del age removes the variable binding from the current namespace—it's not just setting it to a value; the name itself no longer exists. Why the others are wrong: (1) Python doesn't have a default 'undefined' value like JavaScript's undefined—it raises an error; (3) del doesn't reset to 0, it removes the binding entirely; (4) Python doesn't cache previous values this way. Understanding del vs. assignment matters when managing scope and preventing memory leaks in larger programs. Confusing del with assignment is a common misconception."
},
{
question: "A function receives x = [1, 2, 3] as an argument and executes: def modify(lst): lst.append(4). After calling modify(x), what is x?",
options: [
"[1, 2, 3] (the original, unchanged list)",
"[4] (only the appended value is returned)",
"[1, 2, 3, 4] (the list was modified in place)",
"Undefined (the list was deleted inside the function)"
],
correctOption: 2,
explanation: "The list becomes [1, 2, 3, 4] because mutable objects like lists are passed by reference. When modify(x) executes, lst points to the SAME list object as x, so lst.append(4) modifies the original list. Why the others are wrong: (1) The original is changed because it's the same object, not a copy; (3) append() doesn't return a value—it modifies in place; (4) The list isn't deleted, just modified. This is a critical concept: mutating function arguments can have unexpected side effects. Understanding this distinction between passing immutable vs. mutable types is essential for writing bug-free Python and for managing state in larger applications."
},
{
question: "You create: x = 5; y = 5; z = 5. Are x, y, and z the same object in memory?",
options: [
"Yes, for small integers Python caches and reuses objects for efficiency",
"No, each variable creates a separate integer object",
"Only if you use x is y is z syntax",
"It depends on the Python version being used"
],
correctOption: 0,
explanation: "Python caches small integers (typically -5 to 256) for performance. When you create multiple variables with the same small integer value, they often point to the SAME cached object. You can verify this with: x is y returns True (they reference the same object), whereas 257 is not cached, so x = 257; y = 257; x is y returns False. Why the others are wrong: (1) While true for larger integers, small integers are optimized through caching; (3) The is syntax doesn't create this behavior, it just checks if two references point to the same object; (4) This optimization is consistent across Python implementations. Understanding identity (is) vs. equality (==) is crucial for debugging. Many students expect x is y and x == y to always align, but this optimization reveals the distinction."
t },
{
question: "A tuple is described as immutable. Which statement best explains what this means?",
options: [
"A tuple cannot be deleted or reassigned after creation",
"You cannot add, remove, or change elements in a tuple after creation",
a "A tuple cannot be used as a function argument",
"A tuple uses more memory than a list for the same data"
],
correctOption: 1,
explanation: "Immutable means you cannot modify the tuple's contents after creation—no adding, removing, or changing elements. Why the others are wrong: (1) You CAN delete or reassign tuple variables (reassigning the variable, not modifying the tuple); (3) Tuples work fine as function arguments; (4) Memory usage is similar, not related to immutability. The practical implications: (a) Tuples can be dictionary keys because their contents won't change; (b) Tuples are safer for shared data in multi-threaded code; (c) If you need to modify data, use lists instead. This distinction between immutable and mutable types is foundational to Python's design philosophy."
},
{
question: "You write: x = 1.1 + 2.2. When you print(x), you see 3.3000000000000003. Why doesn't it show exactly 3.3?",
options: [
"Python has a bug in its floating-point arithmetic",
"The print() function adds extra precision by default",
s "You must use the Decimal module for all floating-point math",
"Floating-point numbers cannot be represented exactly in binary, causing rounding errors"
],
correctOption: 3,
explanation: "Floating-point numbers are represented in binary (IEEE 754 standard) and some decimal values cannot be represented exactly, causing tiny rounding errors. 3.3 in decimal cannot be perfectly represented in binary, so the closest approximation is stored and displayed. Why the others are wrong: (1) Not a bug—this is inherent to binary floating-point representation in all programming languages; (3) You don't always need Decimal—it's for cases requiring exact decimal arithmetic (financial calculations), but most scientific computing accepts these tiny errors; (4) print() shows the value as stored, not adding precision. Practical implications: avoid comparing floats with == (use abs(x - y) < tolerance instead), and understand when to use Decimal (money) vs. float (science/engineering). This concept separates Python beginners from developers who write correct numerical code."
}
]}
/>Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |