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.
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.
Congratulations!!! you have just executed your first python program from python shell.
2. Using Python program file
Open your favorite text editor and type
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
This will print “Learning Python!” on the terminal.
Congratulations!!! you have just executed your first python script.
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
Finally right click anywhere on the file and Select Run ‘program’. It will execute the program and display the output.