You are on page 1of 9

Keywords

set of predefined words are called keywords


help(‘keywords’)
False class from or
None continue global pass
True def if raise
and del import return
as elif in try
assert else is while
async Except lambda with
await finally nonlocal yield
break for not
firmtech.in 1
Identifiers

Identifier is the name given to the


programming elements such as
variables, functions, classes,
modules, packages.

firmtech.in 2
Variable

variable is a named location used to


store data in the memory
var_A = 15
Var_A = 23
x, y, z = 45, 33.2, "Hello"
Casesensitive ≠ casesensitive
id()
firmtech.in 3
A variable name must start with a letter or
the underscore character
A variable name cannot start with a number
A variable name can only contain alpha-
numeric characters and underscores
(A-z, 0-9, _ )
Variable names are case-sensitive (age, Age
and AGE are three different variables)
firmtech.in 4
Variable
15
var_A = 15
140719346777600
id(var_A)

23
Var_A = 23
id(Var_A) 140719346777856

Var_C = 15
id(Var_C)
Python gives the reference of the
object(value) to the variable
firmtech.in 5
Data Types
• Classification Of The Type Of Values That Can Be
Assigned To Variables
• Operations Are Performed Based On The Values
• Numeric -- int, float, complex
• Sequence -- list, tuple, range
• Text sequence --str
• Mapping --dict
• Set Type – set, frozenset
• Binary sequence – byte, bytearrays
• Boolean
firmtech.in 6
Int
type() – to know the class c = 0b01010101
int are whole numbers, print(type(c))
can be positive, negative d = 0b 11110000
or zero
print(type(d))
a=5
e = 0xface
print(type(a))
f = 0xface
b=0
print(type(e));
print(type(b) print(type(f ))
int can also be represented
Base conversion – bin(),
as binary, octal, and hex(), oct()
hexadecimal with prefix
0b,0B, 0o,0O, 0x,0X Print(bin(a)); print(hex(a))
Print(oct(a)); print(bin(e))
firmtech.in 7
float
floating point contains a decimal point,
expressed in exponential form also
c = 34.6 ; d = -45.765
e = 356.3e5 ; f = 3456.6e-7
g = 123e4 ; h = 123e-4
print(type(c)) ; print(type(d))
round()
round(123.456789,4)
round(h, 3)
firmtech.in 8
Complex
complex numbers are written in the form  a + bj,
where a is the real part and b is the imaginary part
x = 10 + 20j
y = 123.456 + 678.345j
z = 123e4 - 567e-4j
w = 0b1010101010 + 123.456767J
print(type(y)
to get the real and imaginary parts
print(z.real)
print(z.imag)
firmtech.in 9

You might also like