Follow twitter

Python how to run program

For beginners, introduce how to run python program

Launch command prompt ->
Input “python” “space” “Filename”->
Enter

If you like to know how to launch command prompt on Windows, Click here.

This time as an example, let’s try to run helloworld.py file.
helloworld.py contents is just following,

print("Hello World")

Let’s run!
Launch command prompt and input following;

python helloworld.py

1st: input “python”
2nd: input space
3rd: input “the file name”

As a result, “Hello World” is displayed.

If the current directory of command prompt is different from the python file path,
we need to input not only the file name but the file path too as following.

python filepath/helloworld.py

If you feel it’s complicated to input the file path,
you can just drag and drop the file.

Thus common method is following;

– Launch command prompt
– Input “python”
– Input space
– Drag & Drop the file

Have a nice python life!

If it doesn't work…
If you use windows command prompt and it doesn’t work,
try to change the word from python to py.
i.e)python helloworld.py =>py helloworld.py