You can learn about Introduction to Python Programming Programs with Outputs helped you to understand the language better.

Python Programming – Creating a Simple “Hello World” Program

IDLE has two window types, the Shell window, and the Editor window. Python shell window is an interactive interpreter. IDLE includes a text /editor window for opening, editing, and creating modules and scripts. Let us create and save the program in a text editor. To do so, follow the instructions given below: (a) Click on the Start button → All Programs → IDLE(Python 3.7 32-bit. It will display IDLE as shown in Figure 3.15.
When you open IDLE, you will see a window called Python Shell, as shown in Figure 3.15. The Python Shell window runs in interactive mode; it displays the Python prompt, >>>. Typing statements and programs in the Python Shell Interactive mode in IDLE works much the same as an interactive mode in the command line window.
Python Programming – Introduction to Programming chapter 3 img 48
Process of Writing a Program

(b) To open a new text editing window, choose File -3 New File as shown in Figure 3.16.
In Python, the # symbol is used to add comments. Everything from the # to the end of the line is ignored. A comment is a text that you insert into the program for documentation purposes. In this new window, type the following state¬ments:
# My First Program
print (“Hello World”)
After typing two lines of code, your screen appears as shown in Figure 3.17.

Python Programming – Introduction to Programming chapter 3 img 49

Note: In Python, print and Print are two different things, print is a command and Print is just a word. So, if you write Print (“Hello World”), – it will display NameErr or: name ‘Print’ is not defined.

(c) Use File —3 Save or File -» Save As option to save the file. It will display Save As dialog box; type filename says first and click on the Save button. Note that all python programs are saved with. py extension.

Python Programming – Introduction to Programming chapter 3 img 50

Running a Program

(a) To run a program, module or script, make sure it is opened in the text editor, and choose Run —> Run Module or Press F5 key. See Figure 3.19.

Note: The =RESTART= line means that Python is clearing all the work you have previously done before it starts running your program.

If the file is not opened then Click on the File —> Open option to open the saved program, module, or script. The Python Shell restarts (clearing any names that it was storing from the previous session), and Python executes the code as shown in Figure 3.20.

Python Programming – Introduction to Programming chapter 3 img 51

Leave a Reply

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