Python
Python
CONTENTS
o Why Python?
o Data Types
o Operators
o Conditionals
o Loops
o Data Structures
o Functions
Code:
Output:
D ATA T Y P E S
In Python, data types define the nature of values a
variable can hold, such as integers, floats, or strings.
offering flexibility and ease of use.
VA R I A B L E S
A variable is a container that holds or stores data. It
provides a named reference to a value, making it
easier to manipulate and work with that data within a
program.
7
M A K I N G VA R I A B L E S A N D A S S I G N I N G
VA L U E S
O P E R AT O R S I N P Y T H O N
• Arithmetic Operators
• Comparison Operators
• Logical Operators
• Assignment Operators
9
A R I T H M E T I C O P E R AT O R S
10
C O M PA R I S O N O P E R AT O R S
11
A S S I G N M E N T O P E R AT O R S
12
L O G I C A L O P E R AT O R S
CONDITIONALS IN
PYTHON
• IF
• IF ELSE
• IF ELIF ELSE
• NESTED CONDITIONALS
14
IF
15
IF ELSE
16
IF ELIF ELSE
17
NESTED CONDITIONALS
TYPES OF LOOPS
The "for" loop is used to iterate over a The "while" loop is used to repeatedly Authenticates ownership of specific
sequence (such as a list, tuple, string, or execute a block of code as long as a assets
range) and execute a block of code for specified condition is true.
each element in the sequence.
19
FOR LOOP
20
WHILE
LOOP
21
NESTED LOOPS
D ATA S T R U C T U R E S
Tuples Dictionary Strings
LISTS
24
A R R AY
25
SETS
26
TUPLES
27
D I CT I O NARY
28
STRINGS
FUNCTIONS
In Python, a function is a block of reusable code
designed to perform a specific task. Functions are
defined using the def keyword, and they can take
parameters (inputs), perform a set of operations, and
return a result.
C O N N E C T I N G P Y T H O N TO L I N E A R
A LG E B R A