Python's built-in module for virtual environments is 'venv', used with 'python -m venv <env_name>'.
Step 2: Match the correct command
The correct command to create a virtual environment named 'venv' is 'python -m venv venv'.
Final Answer:
python -m venv venv -> Option A
Quick Check:
python -m venv venv = D [OK]
Hint: Use 'python -m venv' to create virtual environments [OK]
Common Mistakes:
Using pip to create virtual environments
Incorrect command order
Confusing Flask commands with environment setup
Omitting '-m' flag
3. Given the following Python code to check Flask version, what will it print if Flask is installed correctly?
import flask
print(flask.__version__)
medium
A. Nothing, it will print a blank line
B. An error message because __version__ is not valid
C. The installed Flask version number, like '2.3.2'
D. The Python version number
Solution
Step 1: Understand flask.__version__ attribute
The Flask package exposes its version as the __version__ attribute, which is a string like '2.3.2'.
Step 2: Predict the print output
When printing flask.__version__, it outputs the version string if Flask is installed properly.
Final Answer:
The installed Flask version number, like '2.3.2' -> Option C
Quick Check:
flask.__version__ prints version = A [OK]
Hint: flask.__version__ shows Flask version if installed [OK]
Common Mistakes:
Expecting an error from __version__
Confusing with Python version
Thinking it prints nothing
Using wrong attribute name
4. You ran pip install Flask but get an error saying 'command not found'. What is the most likely cause?
medium
A. Your internet connection is blocking Flask downloads
B. Flask is not compatible with your Python version
C. You need to run "python flask install" instead
D. You forgot to activate your virtual environment or pip is not installed
Solution
Step 1: Analyze the error message
'command not found' usually means the shell cannot find the pip command, often because the virtual environment is not activated or pip is missing.
Step 2: Evaluate other options
Flask compatibility or internet issues do not cause 'command not found'. The command 'python flask install' is invalid syntax.
Final Answer:
You forgot to activate your virtual environment or pip is not installed -> Option D
Quick Check:
command not found = A [OK]
Hint: Activate venv or ensure pip is installed before running install [OK]
Common Mistakes:
Trying wrong command syntax
Blaming Flask compatibility without checking pip
Ignoring virtual environment activation
Assuming internet issues cause command not found
5. You want to install Flask in a new project but keep dependencies separate. Which sequence of commands correctly sets up a virtual environment and installs Flask inside it?
hard
A. pip install Flask
python -m venv venv
source venv/bin/activate
B. python -m venv venv
source venv/bin/activate
pip install Flask
C. source venv/bin/activate
pip install Flask
python -m venv venv
D. pip install Flask
source venv/bin/activate
python -m venv venv
Solution
Step 1: Create the virtual environment first
Use 'python -m venv venv' to create a clean environment before installing packages.
Step 2: Activate the virtual environment
Run 'source venv/bin/activate' (Linux/macOS) to use the isolated environment.
Step 3: Install Flask inside the activated environment
Run 'pip install Flask' so Flask installs only in this environment.