Congratulations on taking your first step toward learning Python! In this tutorial, we will go over the steps you need to take to run your first Python program on a Windows machine.
Prerequisites
Before you start, you will need to make sure that you have Python installed on your machine. If you don't already have Python installed, you can download it from the official Python website.
Or You can follow this tutorial
How to install Python on Windows
Writing our Code
Once you have Python installed, you are ready to start writing your first program. Here are the steps you need to follow:
- Open your text editor or IDE (Integrated Development Environment). There are many different text editors and IDEs you can use to write Python code, such as
IDLE
(which comes with Python),PyCharm
,VS Code
, orSublime Text
. - Type the following code into your text editor:
Python
print("Hello, World!")
Now
- Save the file as "hello.py". Make sure to save it as a .py file, which indicates that it is a Python script.
- Open a command prompt window by going to the Start menu and typing "cmd" into the search bar.
- Navigate to the directory where you saved the
"hello.py"
file by using the"cd"
command. For example, if you saved the file on the Desktop, you would type"cd Desktop"
to navigate to the Desktop.
Run the script by typing the following command:
CMD
python hello.py
If everything is set up correctly, you should see the message "Hello, World!" printed in the command prompt window.