Introdução ao Python, IDLE e VS Code [Curso de Python: Aula 2]
Table of Contents
Introduction
This tutorial provides a comprehensive guide to getting started with Python programming using IDLE and Visual Studio Code (VS Code). Whether you're a complete beginner or just looking to enhance your skills, this step-by-step guide will help you set up your environment and write your first Python code.
Step 1: Installing Python
-
Download Python:
- Go to the official Python website at python.org.
- Click on the "Downloads" section and select the version suitable for your operating system (Windows, macOS, or Linux).
-
Install Python:
- Run the downloaded installer.
- Make sure to check the box that says "Add Python to PATH" during installation.
- Follow the prompts to complete the installation.
Step 2: Setting Up IDLE
-
Open IDLE:
- After installation, search for IDLE in your applications or programs list.
- Launch IDLE, which is the integrated development environment that comes with Python.
-
Create a New File:
- In IDLE, select
Filefrom the menu, then click onNew File. - This opens a new window where you can write your Python code.
- In IDLE, select
-
Write Your First Program:
- Type the following code in the new file:
print("Hello, World!")
- Type the following code in the new file:
-
Run Your Program:
- Save your file with a
.pyextension (e.g., hello.py). - Press
F5or selectRunfrom the menu and clickRun Moduleto execute your code.
- Save your file with a
Step 3: Setting Up Visual Studio Code
-
Download Visual Studio Code:
- Visit the official VS Code website at code.visualstudio.com.
- Download the version compatible with your operating system.
-
Install Visual Studio Code:
- Run the installer and follow the installation prompts.
- Open VS Code after installation.
-
Install Python Extension:
- Open VS Code and go to the Extensions view by clicking on the Extensions icon in the Activity Bar or pressing
Ctrl+Shift+X. - Search for "Python" and install the official Python extension provided by Microsoft.
- Open VS Code and go to the Extensions view by clicking on the Extensions icon in the Activity Bar or pressing
-
Create a New Python File:
- Click on
File, thenNew File, and save it with a.pyextension (e.g., hello_vscode.py).
- Click on
-
Write and Run Your Code:
- Write the same code:
print("Hello, World!") - To run your code, open the terminal in VS Code by clicking on
Terminalin the menu and selectingNew Terminal. - Type the following command and press
Enter:python hello_vscode.py
- Write the same code:
Conclusion
You have successfully installed Python, set up both IDLE and Visual Studio Code, and run your first Python program. As you progress, consider exploring additional resources, such as online courses for deeper understanding and practice. Happy coding!