1. Get Python on your computer (for Windows 11) -
- Get the Python installer from their website (yellow button)
- Run the installer, select customized installation
- Adjust selections if needed (keep options to install pip and IDLE, and to add to environment variables)
- Open the Command Prompt (type "cmd" in the Windows search bar)
- To test it, type "python --version" (without quotes) in Command Prompt. It should show the version
- At this point, Python files can be run from the command line. See step 3 below
- If it didn't work, look up how to add python to your environment variables
2. (Simplest) Write and Run code with the IDLE+
- Type "IDLE" in the Windows search bar
- Click the IDLE app (which should have been installed with Python)
- Type a simple Python command: print("Testing")
- Press enter to run the code and it should display: Testing
- (Tip) You can use Alt+P to bring previous commands to the current line to edit them
- This tool is good for running single commands, but can get messy for running multiple lines of code together
3. (Optional) Run python files from the Command Prompt +
- Open the Command Prompt and navigate to the Desktop directory/folder with this command: cd Desktop
- Make a directory called JavaPractice: mkdir PythonPractice
- Navigate to the new directory: cd PythonPractice
- Make a java file called myCode.py: notepad myCode.py
- Follow the instructions in the Basics lesson to write a simple program that displays text
- Save the file in Notepad with Ctrl+S or (File -> save)
- Run the python file from the Command Prompt with this command: python myCode.py
- The folder and file names used above (Desktop, PythonPractice, myCode.py) are only examples and can be changed
- If you are unfamiliar with Command Prompt navigation commands, see this tutorial
- This method lets you write and edit code files in Notepad, so the code doesn't clutter the output
4. (Recommended) Set up and use Jupyter Lab (especially for Data Science and ML) +
- Open the Command Prompt
- Install Jupyter Lab with this command: pip install jupyterlab
- Run it with this command: jupyter lab
- Shortly, this should bring up a browser tab with the program running
- In the left column, navigate to the folder where you want to write code
- You can create a folder if needed (e.g. C:\Users\User\MyCoding)
- Create a new notebook (File -> New -> Notebook) and select Python 3 kernel
- Type code into the cell (input line)
- Run the cell with Shift+Enter
- You can add new cells by clicking below the last cell
- Alternatively you can click "+" (in the toolbar) to add a cell below the selected cell
- When done, close the browser tab and then go into Command Prompt and press Ctrl+C
- This tool allows you to easily write and run sections of code separately or all together
5. (Advanced Alternative) Use an IDE (for app development)+
- An IDE (Integrated Development Environment) helps to organize multiple files to work together
- If you already have an IDE, see if there is a Python plugin available
- You can use the free Eclipse IDE and get the PyDev plugin (Help -> Eclipse Marketplace))
- Or you can get a free community version of a paid IDE, such as MS Visual Studio or PyCharm