products:ict:python:writing_and_running_your_first_python_program

How to write and run your first Python program:

Introduction to Python:

Python is a high-level, interpreted programming language known for its simplicity and readability. It is widely used for various purposes such as web development, data analysis, artificial intelligence, scientific computing, and more. Python emphasizes code readability and its syntax allows programmers to express concepts in fewer lines of code compared to other programming languages.

Writing and Running Your First Python Program:

To write and run a Python program, you'll need a text editor and a Python interpreter installed on your computer. Here's how you can do it:

Step 1: Install Python:

If you don't have Python installed on your computer, you can download and install it from the official Python website: [Python.org](https://www.python.org/downloads/).

Step 2: Write Your Python Program:

Open a text editor (such as Notepad, Sublime Text, Visual Studio Code, etc.) and type the following code:

# My First Python Program

print(“Hello, World!”)

This simple program will print “Hello, World!” to the console when executed.

Step 3: Save Your Python Program:

Save the file with a `.py` extension, for example, `first_program.py`. Choose a location where you can easily access it.

Step 4: Run Your Python Program:

Open a terminal or command prompt on your computer. Navigate to the directory where you saved your Python file using the `cd` command.

Once you're in the correct directory, type the following command to run your Python program:

python first_program.py

Replace `first_program.py` with the name of your Python file if it's different.

After running the command, you should see the output “Hello, World!” printed to the console.

Congratulations! You've successfully written and executed your first Python program. From here, you can explore Python's vast ecosystem and learn more about its features and capabilities.

products/ict/python/writing_and_running_your_first_python_program.txt · Last modified: 2024/03/01 18:17 by wikiadmin