Introduction_to_Programming_Python__8_11 (3)
Introduction_to_Programming_Python__8_11 (3)
Chapter 8
Introduction to Python
A programming language is designed to help process certain kinds of data to
provide useful output known as information. The task of processing data is done
by executing a sequence of instructions called a program. These instructions
are written using certain symbols, codes, and words according to some rules
known as syntax or grammar. Like any other programming language, Python
has its vocabulary and grammar.
Python is an interpreter-based, object-oriented programming language. It is a
general-purpose, high-level language with interactive features. It supports the
development of wide range of applications from simple text processing to web
browsers to games. Python is the open source software and was founded by
Guido Van Rossum in 1991. It is named after Python’s Flying Circus, a
comedy program.
Python is the most widely used programming language. Some of the important
places where Python is used are:
Web Programming Development
GUI Application Development
Used for Data Analysis
Software Development
Scientific Applications
Click on the
Download
Python
button with
the latest
version.
1
Python 3.9.5 shell window opens up when we launch IDLE. It is an interactive
window where we can type Python code and view the output in the same
window.
Menu bar
Command
Prompt
1
2
Using print() function – We use the print() function to display the content on
the screen. The content is written within the parentheses.
Step 1: Open the Python shell window.
Step 2: In front of the command prompt, type print(“Hello Class”) and press
Enter key.
Do not forget to include the double quotes (“ ”).
Step 3: The output displays in the next line in the same Python shell window.
Using Python as Calculator
Python command prompt also acts as a calculator. We can use arithmetic
operators like +, -, *, and / to compute any expression.
To perform calculations, follow the steps given below:
1. Type 10 + 10 in front of the command prompt and press Enter key in the
keyboard.
20 is displayed in the next line in the same Python shell window.
2. Now type 100 – 10*2, and press Enter in the keyboard.
Saving a Program
After finishing our
coding, we can save our 1
program. We do not need
to rewrite the same
program every time we
want to use it. 2
For saving a program,
we need to follow the
steps given below:
Step 1: Click on the File
menu.
Step 2: From the drop-down menu, choose Save.
The Save as dialog box appears.
Executing a Program
Once the program is saved, we can execute or run it. For executing a program,
we need to follow the steps given
1
below:
1. Click on the Run menu 2
on the menu bar.
2. From the drop-down,
click on the Run Module
option.
Or
Press the F5 function
key in the keyboard.
Short Key
The output will be displayed in the Python shell window.
To execute a program: F5
Opening a Program
To view the earlier-saved 2
program, we need to 3
follow the given steps:
Step 1: Open Editor’s
window.
Step 2: Click on the File
menu.
Step 3: Choose the Open
option from the drop-
down.
An Open dialog box appears.
Step 4: Select the program to be opened or type name in the File name box.
Step 5: Click on the Open button.
4
Exiting Python
After we are done writing our coding, we can close Python IDLE. To exit
from Python IDLE,
1
we need to follow the
steps given below:
Step 1: Click on the File
menu on the menu bar.
Step 2: From the drop-
down, choose the Exit
option. 2
The Exit option will
close all the open files
and windows, and exit the program. But, if we click on the Close option, it will
close the active file.
Or
Step 1: Type exit() in front of the command prompt.
A confirmation message is displayed.
Step 3: Click OK for exiting Python.