create a python file and run from command line

1 min read

#Mastery01

we are going to create a file for python so we can open it from cmd.

create a text file, I used windows notepad, and name it something like helloworld and change the extension to .py then open it. inside we write: print (“hello world”), save it.

open your cmd and it should say something like:

c:usersname>

we want to change the directory to find the file we created so we add “cd” like this:

c:usersname>cd          

add one space and write the directory where your file is, mine is in desktop:

c:usersname>cd C:UserssergioDesktop     

 and enter. now to open your file:

C:UserssergioDesktop>python helloworld.py

that should do it, for more information i found this video:

https://www.youtube.com/watch?v=hFhiV5X5QM4

CC BY 4.0 create a python file and run from command line by sergio is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.