First Python Program
In this section, you will be writing a simple python program for printing a message as the program output. Python provides a function called print which takes a string and prints it to the console.
There are 2 different ways to write a python program.

1. Using Python Interactive shell
Open Command prompt, type python and hit enter. This will launch python interactive shell which shall look as below.

python interactive shell

For printing a message, write print function with “Learning Python!” as its arguments and hit enter. This will print the message on terminal as shown below.

First python program
Congratulations!!! you have just executed your first python program from python shell.

2. Using Python program file
Open your favorite text editor and type

print("Learning Python!")

Save this file as program.py anywhere on your system.
Now open command prompt, navigate to the location where the above file was saved and type command

python program.py
and hit enter.
This will print “Learning Python!” on the terminal.
Congratulations!!! you have just executed your first python script.

Note: Python command will only work if the path of python of python installation is added to search path of your operating system such as path environment variable on Windows or PATH variable in Linux.

3. Using an IDE
Open your favorite IDE and create a new project. On PyCharm, go to File -> New Project, give your project a name and hit Enter. Next right click of the project and select New -> Python File. Write the above print statement in that file.
Finally right click anywhere on the file and Select Run ‘program’. It will execute the program and display the output.

0

Leave a Reply

Mark Your Impression

  Subscribe  
Notify of
Close Menu

Never Miss an article !

Get the new post delivered straight into your inbox, enter your email and hit the button

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

codippa will use the information you provide on this form to be in touch with you and to provide updates and marketing.