Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the main purpose of using conda for environment management?
Conda helps create isolated environments to keep project dependencies separate, avoiding conflicts between packages.
Click to reveal answer
beginner
How does pip differ from conda in managing packages?
Pip installs Python packages from the Python Package Index (PyPI), while conda manages packages and environments for multiple languages, including Python.
Click to reveal answer
beginner
What command creates a new conda environment named myenv with Python 3.9?
conda create -n myenv python=3.9
Click to reveal answer
beginner
How do you activate a conda environment called myenv?
conda activate myenv
Click to reveal answer
beginner
How can you install a package named requests inside an active conda environment using pip?
pip install requests
Click to reveal answer
Which command lists all conda environments on your system?
Apip env list
Bpip list
Cconda env list
Dconda list env
✗ Incorrect
The command conda env list shows all conda environments available.
What does the command pip freeze do?
ARemoves all installed packages
BCreates a new environment
CUpdates pip to the latest version
DShows installed packages and their versions
✗ Incorrect
pip freeze lists all installed packages with exact versions, useful for sharing dependencies.
How do you deactivate the current conda environment?
Aconda deactivate
Bpip deactivate
Cconda stop
Dpip stop
✗ Incorrect
Use conda deactivate to exit the active conda environment.
Which file is commonly used to save pip package dependencies for sharing?
Arequirements.txt
Benvironment.yml
Csetup.py
Dconda.yaml
✗ Incorrect
requirements.txt lists pip packages and versions for easy installation.
What is the purpose of the environment.yml file in conda?
ATo list pip packages only
BTo define environment name and packages for conda
CTo update conda itself
DTo uninstall environments
✗ Incorrect
environment.yml describes a conda environment including its name and packages.
Explain how to create, activate, and deactivate a conda environment.
Think about commands to start and stop using an isolated space for your project.
You got /3 concepts.
Describe the differences and roles of conda and pip in environment and package management.
Consider what each tool controls and where they get packages from.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of using conda create -n myenv python=3.8?
easy
A. To delete the environment named 'myenv' and install Python 3.8 globally
B. To update Python to version 3.8 in the current environment
C. To create a new isolated environment named 'myenv' with Python 3.8 installed
D. To install all packages listed in a file named 'myenv' with Python 3.8
Solution
Step 1: Understand the conda create command
This command is used to create a new environment in conda, isolating packages and Python versions.
Step 2: Analyze the flags and arguments
The -n myenv specifies the environment name, and python=3.8 sets the Python version inside it.
Final Answer:
To create a new isolated environment named 'myenv' with Python 3.8 installed -> Option C
Quick Check:
conda create -n myenv python=3.8 = D [OK]
Hint: Remember: 'conda create -n' makes new isolated envs [OK]
Common Mistakes:
Confusing 'create' with 'install' or 'update'
Thinking it affects the global Python installation
Misunderstanding the '-n' flag as package name
2. Which of the following commands correctly activates a conda environment named dataenv?
easy
A. activate conda dataenv
B. conda activate dataenv
C. conda start dataenv
D. source deactivate dataenv
Solution
Step 1: Recall the syntax to activate conda environments
The correct command to activate an environment is conda activate <env_name>.
Step 2: Check each option
conda activate dataenv matches the correct syntax. Options B, C, and D use incorrect command order or wrong commands.
Final Answer:
conda activate dataenv -> Option B
Quick Check:
Activate env = conda activate env_name [OK]
Hint: Use 'conda activate env_name' to switch environments [OK]
Common Mistakes:
Using 'activate conda' instead of 'conda activate'
B. No output because pip list does not work inside conda
C. Error: 'pip' command not found
D. List of all packages except numpy
Solution
Step 1: Understand environment creation and activation
The environment 'testenv' is created with Python 3.9 and then activated, so all commands run inside it.
Step 2: Installing numpy with pip inside the active environment
Running pip install numpy installs numpy in 'testenv'. The pip list | grep numpy command will show numpy and its version.
Final Answer:
numpy with its installed version number -> Option A
Quick Check:
pip install inside active env = numpy listed [OK]
Hint: pip installs packages in active conda env, visible with pip list [OK]
Common Mistakes:
Thinking pip installs globally ignoring conda env
Assuming pip commands fail inside conda
Expecting no output from pip list
4. You run conda activate myenv but get the error: CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. What is the most likely fix?
medium
A. Reinstall Python globally on your system
B. Deactivate any active environment before activating 'myenv'
C. Use pip install conda to fix the error
D. Run conda init to configure your shell, then restart the terminal
Solution
Step 1: Understand the error cause
This error means the shell does not know how to run conda activate because it lacks proper initialization.
Step 2: Apply the fix by initializing conda for the shell
Running conda init sets up the shell scripts needed. Restarting the terminal applies changes.
Final Answer:
Run conda init to configure your shell, then restart the terminal -> Option D
Quick Check:
Shell config for conda = conda init + restart [OK]
Hint: Run 'conda init' once after install, then restart terminal [OK]
Common Mistakes:
Trying to reinstall Python instead of fixing shell config
Using pip to install conda which is incorrect
Ignoring the need to restart terminal after init
5. You want to create a reproducible environment for a project using conda and pip. Which sequence of commands correctly creates an environment, installs packages from a requirements.txt file using pip, and exports the environment including pip packages?