Creating Your First Python Program

You can run python programs in two ways, first by typing commands directly in python shell or run program stored in a file. But most of the time you want to run programs stored in a file.

Lets create a file named  in your documents directory  i.e C:\Users\YourUserName\Documents using notepad (or any other text editor of your choice) , remember python files have ‘.py’ extension, then write the following code in the file.

In python we use print  function to display string to the console. It can accept more than one arguments. When two or more arguments are passed, print  function displays each argument separated by space.

Expected output

Now open terminal and change current working directory to C:\Users\YourUserName\Documents  using cd  command.

To run the program type the following command.

Leave a Reply

Your email address will not be published. Required fields are marked *