chore: import upstream snapshot with attribution
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 11:55:53 +08:00
commit dde272c4b8
19405 changed files with 2730632 additions and 0 deletions
@@ -0,0 +1,157 @@
---
id: 67fe8567f141d632afaeb71b
title: How Do You Install, Configure and Use Python in Your Local Environment?
challengeType: 19
dashedName: how-do-you-install-configure-and-use-python-in-your-local-environment
---
# --description--
For all of the workshops and labs, you will be using freeCodeCamp's Python editor. But it is important to learn how to set up Python on your local machine.
The easiest way to install Python on Windows and Mac is to download the installer from the official Python website. We'll also go over running Python on Linux later in this lesson.
Go to `https://www.python.org/` and hover over "Downloads". A modal will appear showing the current version of Python for your operating system (OS).
We'll go over how to install Python on a computer running macOS first:
- Click on the button showing the current version of Python (from the previous modal), and you'll start downloading a `.pkg` installation file automatically.
- Once the `.pkg` installer is finished downloading, open it, then click "Continue" in the window that opens up.
- Continue clicking the "Continue" button until you get to the "Installation Type" section. There, click the "Install" button.
- Enter your password if necessary, then start the installation.
- After that, you should get a congratulations message saying that Python has been successfully installed.
- Click the "Close" button, and you're done!
You can verify the installation by opening up your terminal and running `python --version` or `python3 --version`.
You can also open the Python interpreter by running `python` or `python3` in the terminal. A Python interpreter is the program that reads Python code, translates it into instructions the computer understands and executes those instructions.
A <dfn>terminal</dfn> is a text-based interface that lets you interact with your computer by typing commands. Each operating system comes with a default terminal app. On macOS, you can use the Terminal app. On Windows, you can use Command Prompt or PowerShell. On Linux, each desktop environment has its own default terminal app, like GNOME Terminal or Konsole.
Note that, on some older macOS and Linux systems, `python` can be reserved for Python 2, while `python3` is for Python 3 specifically. If you run `python --version` and see a version of Python 2 like `Python 2.7.18`, then it's possible that your OS relies on some software that was written in the older version of Python. If that's the case, you should use `python3` to run your Python code going forward. Python 2 is end-of-life and should not be used for any new development.
To install Python on Windows, follow these steps:
- Go to `https://www.python.org/`, and hover over “Downloads“. You should see a modal that says "Download for Windows" and a download button with the current version of Python.
- Click on the version number, and you'll start downloading a Windows executable (`.exe`) file automatically.
- Once you've finished downloading the Python installer for Windows, double-click on it, and follow the instructions.
- When you see the option `Add python.exe to Path`, check that option, then click `Install Now`. Doing that will make things easier for you later.
You can verify the installation by opening up a command line shell like PowerShell and running `python --version`. You can also open the Python interpreter by running `python`.
For Python on Linux, most major distros like Ubuntu, Debian, and Fedora come with Python.
Just open a terminal and run `python --version`, or `python3 --version`:
If either command doesn't show a version of Python, you can search for an installation package for your flavor of Linux at `https://www.python.org`, or search online for the recommended way to install Python for your distro.
# --questions--
## --text--
Which address can you download Python from?
## --answers--
`wikipedia.org`
### --feedback--
Think about the official Python website.
---
`python3.com`
### --feedback--
Think about the official Python website.
---
`python3.org`
### --feedback--
Think about the official Python website.
---
`python.org`
## --video-solution--
4
## --text--
How can you get Python added to `path` automatically on Windows?
## --answers--
By installing Python.
### --feedback--
Review the last part of the lesson.
---
By checking the "add to path" checkbox during the installation process.
---
By checking the "use admin privileges" checkbox.
### --feedback--
Review the last part of the lesson.
---
By downloading Python from `python.org`.
### --feedback--
Review the last part of the lesson.
## --video-solution--
2
## --text--
What kind of file do you download while installing Python for Windows?
## --answers--
A package file (`.pkg`)
### --feedback--
Think about the extension of the file that you download when you want to install Python.
---
An AVI file.
### --feedback--
Think about the extension of the file that you download when you want to install Python.
---
An executable (`.exe`)
---
An executable JSON file
### --feedback--
Think about the extension of the file that you download when you want to install Python.
## --video-solution--
3
@@ -0,0 +1,175 @@
---
id: 69fd6b21fcaa14b089c27182
title: How to Run Python Scripts
challengeType: 19
dashedName: how-to-run-python-scripts
---
# --description--
In the previous lesson, you learned how to install Python on your local device. In this lesson, you will learn how to run Python code locally.
Before you can start building your Python scripts locally, you will need to install a code editor or IDE. IDE stands for Integrated Development Environment and it has features including a code editor, testing tools, a terminal and more.
One popular code editor that many developers use is VS Code. Visit `https://code.visualstudio.com/download` to download VS Code which supports Mac, Windows and Linux environments. This is the editor that will be used in this lesson.
Other common choices for Python development include the following:
- PyCharm
- Spyder
Once you have downloaded your editor, you will need to open it. Once it is opened, you will need to open a folder. You can click on the `File` menu option in the upper left hand corner and click on `Open Folder`. From there, you can choose or create a folder for your project. For extra practice outside of the lesson, you might want a folder named `python-projects`.
Once you have your folder set up, you can open the explorer which is the left sidebar in VS Code. Click on the `New File` icon which looks like a piece of paper with a plus icon over it. Then create a file called `main.py` and press enter. The `.py` is a file extension signalling this is a Python file.
Open up your `main.py` file and type the following code:
```py
print("Hello, world!")
```
To run this code, you have a few options. The first option is to click on the run button which looks like a play button located in the upper right hand corner. That will open a terminal and run your Python script there. You should see the text `"Hello, world!"`.
Another option is to open a terminal and manually run the program using:
```bash
python main.py
```
You must run this command from the folder where `main.py` is saved. For example, if `main.py` is inside a folder called `python-projects`, first use the following in the terminal:
```bash
cd python-projects
```
Then run:
```bash
python main.py
```
In some environments, especially on macOS and Linux systems where Python 2 and Python 3 are both installed, you may need to use `python3` instead of `python`. This is common when the `python` command either does not exist or points to an older version of Python.
```bash
python3 main.py
```
As you progress throughout the course, you should try the examples from the lessons locally and see the results. You should also try to come up with your own examples to test what you have learned from the lessons.
# --questions--
## --text--
Which of the following is NOT a commonly used editor or IDE for Python development?
## --answers--
Clang
---
VS Code
### --feedback--
Refer back to the beginning of the lesson for the correct answer.
---
Spyder
### --feedback--
Refer back to the beginning of the lesson for the correct answer.
---
PyCharm
### --feedback--
Refer back to the beginning of the lesson for the correct answer.
## --video-solution--
1
## --text--
What does IDE stand for?
## --answers--
Internal Development Environment
### --feedback--
Refer back to the beginning of the lesson for the correct answer.
---
Integrated Development Environment
---
Integrated Development Eval
### --feedback--
Refer back to the beginning of the lesson for the correct answer.
---
Integrated Deno Environment
### --feedback--
Refer back to the beginning of the lesson for the correct answer.
## --video-solution--
2
## --text--
Which of the following is the correct command to use if you want to run a Python script in the terminal?
## --answers--
```bash
pip main.py
```
### --feedback--
Refer to the end of the lesson for the answer.
---
```bash
pyrun main.py
```
### --feedback--
Refer to the end of the lesson for the answer.
---
```bash
python main.py
```
---
```bash
piode main.py
```
### --feedback--
Refer to the end of the lesson for the answer.
## --video-solution--
3
@@ -0,0 +1,179 @@
---
id: 69fd75321df075656f836fff
title: How to Use the Python Interactive Shell
challengeType: 19
dashedName: how-to-use-the-python-interactive-shell
---
# --description--
In the previous lesson, you learned how to run Python scripts locally. But there might be times where you don't want to create full Python programs and just need to test out some Python code. This is where the Python interactive shell comes in.
But first, let's review what a terminal is.
A terminal is a text-based interface that lets you interact with your computer by typing commands. Each operating system comes with a default terminal app. On macOS, you can use the Terminal app. On Windows, you can use Command Prompt or PowerShell. On Linux, each desktop environment has its own default terminal app, like GNOME Terminal or Konsole.
Open up a terminal app and type in `python` and press `Enter`. This will start a Python interactive shell. An interactive shell is a program that lets you type commands one at a time and see the results.
When you start a new session, you might see this type of output initially:
```bash
Python 3.12.2 (main, Mar 21 2024, 22:48:26) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
```
The `>>>` symbol means Python is waiting for you to type a command. Try printing `"Hello, world!"` to the terminal:
```bash
print("Hello, world!")
```
You should see the text appear like this:
```bash
>>> print("Hello, world!")
Hello, world!
```
After the text is printed, Python goes back to the following:
```bash
>>>
```
This means you can type in another command.
The Python interpreter is following what is known as the Read, Evaluate, Print, Loop cycle. Or REPL for short. Whenever you type in commands, the interpreter will read the input, evaluate it, print the result and loop back to show the `>>>` so you can type more commands.
What happens if you try to type in an invalid command like this?
```bash
>>> something random
```
Well, the Python interpreter will still follow the same REPL process. In this case, you will get an error message:
```bash
>>> something random
File "<stdin>", line 1
something random
^^^^^^
SyntaxError: invalid syntax
```
If you want to leave the interactive shell you can type `exit()` or press `Ctrl + D` for (Mac/Linux) or `Ctrl + Z + Enter` for (Windows).
Using Python's interactive shell is great for small experiments with code or basic exploration. While you are going through the remaining lessons in the course, you can type in some of the new methods you learned inside an interactive shell.
If you are planning to work with longer programs or working across multiple files, then it is better to work in a code editor or IDE.
# --questions--
## --text--
What is an interactive shell?
## --answers--
A program used to format Python code.
### --feedback--
Refer back to the beginning for the correct answer.
---
A program that lets you type commands one at a time and see the results.
---
A program used to lint Python code.
### --feedback--
Refer back to the beginning for the correct answer.
---
A program that lets you download popular Python libraries.
### --feedback--
Refer back to the beginning for the correct answer.
## --video-solution--
2
## --text--
What does REPL stand for?
## --answers--
Run, Execute, Process, Launch
### --feedback--
Refer back to the end for the correct answer.
---
Read, Execute, Print, Load
### --feedback--
Refer back to the end for the correct answer.
---
Read, Evaluate, Print, Loop
---
Read, Enter, Parse, Log
### --feedback--
Refer back to the end for the correct answer.
## --video-solution--
3
## --text--
Which of the following is a correct way to leave an interactive shell?
## --answers--
Type `exit()` in the terminal.
---
Type `stop()` in the terminal.
### --feedback--
Refer back to the end for the correct answer.
---
Type `end()` in the terminal.
### --feedback--
Refer back to the end for the correct answer.
---
Type `terminate()` in the terminal.
### --feedback--
Refer back to the end for the correct answer.
## --video-solution--
1