← All Python MCQ topics and your readiness dashboard
Test your Modules, Packages and Virtual Environments knowledge with a timed Python MCQ mock test for interviews. Each attempt gives you 20 random questions in 20 minutes from a 200-question bank covering import styles, sys.path and sys.modules, the __main__ guard, packages, __init__.py and relative imports, __all__, circular imports and shadowed names, importlib, venv creation and activation, pip, requirements, version pins and lock files, pyproject.toml, and test project setup: conftest.py, plugins, CI installs, secrets and reproducible environments. 50 questions are written from a QA and test-automation angle and the rest from a developer angle; your result shows both scores.
What this Python MCQ test covers
Revise these lessons from the free Python tutorial before or after your test:
Sample Python Modules & venv questions with answers
- Q. Choosing settings per environment. What does this code print?
import os
os.environ["TEST_ENV"] = "staging"
URLS = {"dev": "http://localhost:3000", "staging": "https://staging.example.com"}
print(URLS[os.getenv("TEST_ENV", "dev")])
Answer:https://staging.example.com
Reading the environment from an env var lets the same tests target any environment. - Q. Skipping when an optional dependency is missing. What does this code print?
import importlib.util
HAS_PANDAS_X = importlib.util.find_spec("pandas_not_installed_xyz") is not None
print("run" if HAS_PANDAS_X else "skip: needs pandas_not_installed_xyz")
Answer:skip: needs pandas_not_installed_xyz
pytest.importorskip does this for you inside tests. - Q. Recording the environment in a test report. What does this code print?
import sys, platform
meta = {"python": f"{sys.version_info.major}.{sys.version_info.minor}", "os": platform.system()}
print(sorted(meta), meta["python"].count("."))
Answer:['os', 'python'] 1
Store the Python version and OS with results so failures can be reproduced. - Q. What does this code print?
import math
print(math.sqrt(16), math.floor(2.7), math.ceil(2.1))
Answer:4.0 2 3
math.sqrt returns a float; floor and ceil return ints. - Q. What does this code print?
from math import pi, sqrt
print(round(pi, 2), sqrt(9))
Answer:3.14 3.0
from module import name brings names directly into scope. - Q. What does this code print?
import math as m
print(m.factorial(4), m.gcd(12, 18))
Answer:24 6
import … as gives the module a shorter alias.
Every predict-the-output question in this bank was run on Python 3, so the answer is the real output. Go back to the Python MCQ dashboard to see your overall Python learning progress and interview readiness.
Frequently asked questions
How many questions does the Python Modules & venv MCQ test have?
The bank has 200 questions. Each test picks 20 at random, favouring questions you have not seen yet, so about 10 attempts cover the whole bank.
How long is each test and what is the pass mark?
Each test has a 20-minute timer and submits itself when time runs out. You pass with 70%, which is 14 of 20 correct.
Is this test useful for QA and automation engineer interviews?
Yes. 50 of the questions use test-automation scenarios such as parsing UI text, test data and assertions, and your result shows your QA score separately.
Can I retake the test?
Yes, as often as you like. Every retake draws a fresh set of 20 questions and counts toward your 20-test readiness target.