Grade 7- Introducing Python- Part_1
Grade 7- Introducing Python- Part_1
Introducing
Python
What is a Programming
Language
☞ English, Kannada, Hindi are natural languages.
It has words, symbols and grammatical rules.
☞ A programming language is set of instructions
given to computer to perform a particular task.
☞ A programming language also has words,
symbols and rules of grammar.
☞ The grammatical rules are called SYNTAX.
☞ Modern computers can follow the generalized
set of operations called programs.
☞ A program is an sequence of instructions that
specifies how to perform a computation.
RECIPE FOR TOMATO PASTA
Simmering the
ingredients is
The product
after processing
is output, in our
example pasta.
Programming language
Introduction to
Python
⮚ Python is a simple programming
language used to write codes for
computer programs.
⮚ Python was created by Guido Van
Rossum when he was working at CWI
(centrum Wiskunde & Informatics),
which is a National Research Institute
for Mathematics and Computer
Science in Netherlands. The language
was released in 1991.
⮚ Python is a high-level programming
language.
Some of the features which make
Python so popular are as follows:
❖ Build a website
❖ Develop Games
❖ Program Robots
❖ Perform Scientific
Computations
❖ Develop Artificial Intelligence
Applications.
Installing Python
🞇 Step 1. Go to website address
http://www.python.org/download
Step 2. Python Installation Process
⮚ Click on RUN in the dialog box the installation process starts.
⮚ Keep following the instructions and keep clicking on next
button until you see the highlighted Finish button.
The Python IDLE
(Integrated Development
Click on and Learning Environment)
IDLE Executes instructions, one
Python line at a time.
Components of Python
Window
Title Bar Menu Bar
Python
Prompt
Script Area
Status Bar
Components of Python
Window
✔ Title Bar
✔ Menu Bar
✔ Working with File Menu
✔ Working with Edit Menu
✔ Working with Help Menu
✔ Script Area
✔ Status Bar
Two Modes
Interactive Script
Mode Mode
e is
Interactive mod
beneficial for
ere
testing code wh
you type the
at a
c om m a n d s o n e
e
time and get th
result or error
immediately.
Use of Interpreter
•Variables represent
named storage
locations.
Empty Storage
A variable can locations
store only one
data value at a
time.
A storage
holding a
food.
The Assignment Operator(=)
•Python variables
are created by
assigning values
of desired type to
them.
Ex: x=42
▪ A variable
name can be of
any length
▪ Variable names
are case-
sensitive
▪ If a variable is
used without
assigning a
value, it gives
an error.
Rules to write the variable names
or Identifiers.
⮚ The first character must be a letter
⮚ Upper case and lower case are different.
⮚ Digits (0 to 9) can be a part of identifies except first
character.
⮚ It can’t be a keyword of python.
⮚ Can’t contain any special character except
underscore(_).
🞇 The following characters are valid:
🞇 Lowercase letters (a to z)
🞇 Uppercase letters (A to Z)
🞇 Digits (0 to 9)
🞇 Underscore (_)
Examples of
Valid Variable names Invalid Variable names
🞇 Class
🞇 Employee code
🞇 emp_code
🞇 10code
🞇 age1980
🞇 A.B.C Ltd
🞇 a145r
🞇 tm@ltd
🞇 Four
🞇 Else
🞇 bal_fee
Swapping variables:
a, b = 30, 50
print (a, b) # 30 50
a, b = b, a
print (a, b) # 50 30