Python
Python
Notes
PYTHON
DATA
TYPES
IN
STRING Anything in double quotes
A-Z
a-z
NUMBERS
Integers Whole Numbers
Signed (+)
Unsigned (-)
Float Decimals
NONE
Operators-
Types of Operators-
1) Arithmetic Operator:
Definition – The type of operator used to perform
basic mathematical calculation
A] Unary Operators: -
Definition- The arithmetic operator that can operate
only one operand.
E.g.} a= (-100)
print a
-100
B] Binary Operators: -
Definition- The arithmetic operator that can operate 2
or more operands.
Types of Binary Operators-
[i] Addition (+)
Use – To obtain the sum of the values.
E.g. – 13+3.5=16.5
2) String Operator:
Definition – The type of operator used to join and
replicate string values
A] Concatenation Operator [+] : -
Definition- The string operator that can join 2 or
more values.
E.g.} x = 12
y=2
print (x*y)
24
4) Relational Operators:
Definition – The type of operator used to compare
operands.
Note – In Python result provided is in Boolean
expression type i.e., true or false
Operator Symbol
Less Than <
Less Than or Equal to <=
Equal to ==
Greater Than >
Greater Than or Equal >=
to
Not Equal to !=
Expression Result
y<x True
y<=x True
x==x True
y>x False
y>=x False
y!=x True
x=12 y=2
5) Precedence Operators:
Definition – The type of operator used to evaluate
according to an order from highest to lowest priority.
Bracket
Open
Division E.g.} 10/ (3+2)
AND & OR
Practical
Theory
E.g. 1} p=int(input(“ ”)) Have to
t=int(input(“ ”)) pass in
if p>35 AND T>35 both
print (“pass”) criteria
else or it is a
print (“fail”) failure
Control Statements-
TYPE OF
STATEMENTS IN
Sequential Repetitive
Conditional
Control Structures that govern flow of
execution in programs-
1) Sequential Structures:
Definition – The statements in a program are
executed in a sequential manner, i.e., one after
another with no possibility of branching off to
another action are known as Sequential statements.
2) Conditional Structures:
Definition – Definition- Conditional statements are
the type of statements that check the condition and
execute statements accordingly.
E.g.}
Condition Plan of Action
If age>=18 Then you can apply for driver’s license.
3) Iterative Structures:
Definition – Iterative statements (looping statements)
enable execution of a set of statements to be repeated
till the condition is true.
Conditional Statements-
Definition- Conditional statements are the type of
statements that check the condition and execute
statements accordingly.
Syntax} if <condition>:
statement set 1
elif <condition 2>:
statement set 2
elif <condition 3>: