DEV Community

Dr. Azad Rasul
Dr. Azad Rasul

Posted on

5- How to run a Python program?

For short commands, we do not need to write scripts. We use command line: In the search window of Windows write:

cmd
Enter fullscreen mode Exit fullscreen mode

Then click Enter to open command prompt.

To open Python, inside the command prompt write:

python
print("Hello World!")
### Hello World!
Enter fullscreen mode Exit fullscreen mode

To close the Python use:

exit()
Enter fullscreen mode Exit fullscreen mode

Write a simple python file

Open Notepad, inside notepad, write: print("Hello, World!"), then save it as: helloworld.py

To run a python file on the command line: Change the directory to the folder (e.i. Python38) that includes the file. then we use command: python file-name.py

cd C:\Python38

python helloworld.py
### Hello, World!
Enter fullscreen mode Exit fullscreen mode

helloworld is the name of the file.

Congratulations, you have written and executed your first Python program.

If you like the content, please SUBSCRIBE to my channel for the future content.

To get full video tutorial and certificate, please, enroll in the course through this link: https://www.udemy.com/course/python-for-researchers/?referralCode=886CCF5C552567F1C4E7

Top comments (0)