40 lines
3.1 KiB
JSON
40 lines
3.1 KiB
JSON
{
|
|
"questions": [
|
|
{
|
|
"stage": "pre",
|
|
"question": "What problem do virtual environments solve?",
|
|
"options": ["They make Python code run faster by optimizing the interpreter", "They isolate project dependencies so different projects can use different package versions", "They provide a graphical interface for managing Python scripts", "They automatically update packages to the latest versions"],
|
|
"correct": 1,
|
|
"explanation": "Virtual environments give each project its own isolated set of packages. Without them, installing PyTorch 2.4 for one project would overwrite PyTorch 2.1 needed by another."
|
|
},
|
|
{
|
|
"stage": "pre",
|
|
"question": "What is a lockfile in the context of Python dependency management?",
|
|
"options": ["A file that prevents other users from editing your code", "A file that pins every package to an exact version for reproducible installs", "A file that locks the Python interpreter version", "A file that encrypts your project dependencies"],
|
|
"correct": 1,
|
|
"explanation": "A lockfile records the exact version of every package (including transitive dependencies) so anyone installing from it gets identical packages, ensuring reproducibility."
|
|
},
|
|
{
|
|
"stage": "post",
|
|
"question": "How can you verify that your pip and python commands are using the virtual environment and not the system Python?",
|
|
"options": ["Run 'pip --version' and check the version number", "Run 'which python' and confirm it shows .venv/bin/python, not /usr/bin/python", "Check if the terminal background color has changed", "Run 'python --check-env' to verify"],
|
|
"correct": 1,
|
|
"explanation": "'which python' (or 'where python' on Windows) shows the full path to the interpreter. If it points to .venv/bin/python, you are in the virtual environment."
|
|
},
|
|
{
|
|
"stage": "post",
|
|
"question": "Why is mixing pip and conda in the same environment problematic?",
|
|
"options": ["Pip packages are incompatible with conda's Python interpreter", "Pip installs can break conda's dependency tracking, causing hard-to-debug conflicts", "Conda cannot install packages that pip has already installed", "It doubles the disk space used by every package"],
|
|
"correct": 1,
|
|
"explanation": "Conda maintains its own dependency solver. Pip installs bypass it, so conda no longer knows the true state of the environment. This leads to dependency conflicts that are painful to resolve."
|
|
},
|
|
{
|
|
"stage": "post",
|
|
"question": "Your PyTorch code reports 'CUDA not available' despite having an NVIDIA GPU. What is the most likely cause?",
|
|
"options": ["Your GPU does not support CUDA", "PyTorch was installed with a CUDA version incompatible with your GPU driver", "You forgot to import the torch.cuda module", "Virtual environments cannot access GPU hardware"],
|
|
"correct": 1,
|
|
"explanation": "PyTorch ships CUDA bindings compiled for specific CUDA versions. If the PyTorch CUDA version exceeds your driver's CUDA version, CUDA will not be available. Check with nvidia-smi and torch.version.cuda."
|
|
}
|
|
]
|
|
}
|