Introduction to Python
What is Python?
• Python is high level language
3
print(“hello world!”)
4
A Python identifier is a name used to identify a
variable, function, class, module or other object.
5
▪ Identifiers can be a combination of letters in
lowercase (a to z) or uppercase (A to Z) or digits (0
to 9) or an underscore _. Names like myClass,
var_1 and print_this_to_screen, all are valid
example.
▪ An identifier cannot start with a digit. 1variable is
invalid, but variable1 is a valid name.
▪ Keywords cannot be used as identifiers.
▪ We cannot use special symbols like !, @,#, $, %
etc. in our identifier.
▪ An identifier can be of any length.
6
Keywords are reserved words and you cannot
use them as constant or variable or any other
identifier names. All the Python keywords
contain lowercase letters only.
7
and exec not
assert finally or
break for pass
class from print
continue global raise
def if return
del import try
elif in while
else is with
8
COMMENTS IN
PYTHON
Single Line Comments: Python single line comment
starts with hashtag symbol with no white spaces (#)
and lasts till the end of the line.
9
COMMENT
sINP
Y
T
H
O
N
Multi-Line Comments: Python multi-line comment is
a piece of text enclosed in a delimiter (""") on each
end of the comment.
10
VARIABLES
Reserved memory locations to store values
11
UsINGV
ARIABLEsINP
Y
T
H
O
N
Assignment operator (=)is used to
assign a value to a variable.
12
D
A
T
ATYPEsIN
P
Y
T
H
O
N
String: sequence of characters surrounded by quotes.
Numeric: they are of three types:
▪ Integer
▪ Float
▪ Complex
Boolean: It can have only two values (true/false)
13
C
O
L
L
E
CT
I
O
N
s
Lists: List is an ordered sequence of items. All the
items in a list do not need to be of the same type.
14
C
O
L
L
E
CT
I
O
N
s
Tuple: They are like lists but cannot be modified.
15
C
O
L
L
E
CT
I
O
N
s
Set: Set is a unordered collection of unique items.
16
C
O
L
L
E
CT
I
O
N
s
Dictionary: Dictionary is an unordered collection of
key-value pairs. It is generally used when we have a
huge amount of data. Dictionaries are optimized for
retrieving data. Wemust know the key to retrieve the
value.
17
INPUTINP
Y
T
H
O
N
Using input()
18
19
EXERCIsE
20
1. Write a program to enter a number and print 5 times of
that number. (number *5).
2. Write a program to define a set of numbers in table of
19.
3. Write a program to input two numbers and print their
sum.
SOL
UTIONs
21

Jas_python.pptx for beginners introduction