
Writing and Running Your First Python Program
Now that you have Python installed and a code editor set up, it's time to write your first Python program! In this topic, we'll cover the basic steps for writing and running a simple "Hello, World!" program.
Step 1: Open your code editor
Open your code editor (in our case, Visual Studio Code) and create a new file. You can name the file anything you like, but it should have the ".py" file extension to indicate that it contains Python code.
Step 2: Write your code
In the new file, type the following code:
print("Hello, World!")
This code uses the built-in print function to output the text "Hello, World!" to the console.
Step 3: Save your file
Save your file with a descriptive name and the ".py" file extension. For example, you could name the file "hello_world.py".
Step 4: Run your program
To run your program, open a terminal or command prompt and navigate to the directory where you saved your file. Then type the following command:
python hello_world.py
This will execute your Python program and output the text "Hello, World!" to the console.
Congratulations, you've written and run your first Python program! In the next topic, we'll cover the basics of data types and variables in Python.
0 Comments: