To install Python and write/run your first Python program, you can follow these step-by-step instructions:
Step 1: Download Python
Visit the official Python website (https://www.python.org) and go to the Downloads section. Choose the appropriate version of Python for your operating system (Windows, macOS, or Linux) and download the installer.
Step 2: Run the Installer
Once the installer is downloaded, run it and follow the on-screen instructions. Make sure to select the option to add Python to the system PATH during the installation process. This will allow you to run Python from the command prompt or terminal.
Step 3: Verify the Installation
After the installation is complete, open the command prompt or terminal and enter the following command to check if Python is installed correctly:
python --version
You should see the version number of Python printed on the screen.
Step 4: Write Your First Python Program
Open a text editor or an Integrated Development Environment (IDE) to write your Python program. Start by creating a new file with a .py
extension, for example, first_program.py
.
In your text editor or IDE, enter the following code as your first Python program:
print("Hello, World!")
Step 5: Save the File
Save the file in a directory of your choice with the .py
extension. For example, save it as first_program.py
.
Step 6: Run the Python Program
To run your Python program, open the command prompt or terminal and navigate to the directory where you saved the first_program.py
file. Use the following command to execute the program:
python first_program.py
You should see the output “Hello, World!” printed on the screen.
Congratulations! You have successfully installed Python and written/run your first Python program. You can now continue exploring Python and its vast ecosystem to develop more complex applications.