PYTHON
Python
Introduction 1
Core Data Structure 2
Control Flow Statements 3
Introduction
Python, created by Guido van Rossum. Python
is a high-level, open-source, general-purpose
programming language .It is known for its
simple and readable syntax, making it easy to
learn and write.
Popular for: web development, software
engineering, data science, machine
learning, artificial intelligence, automation,
and more.
Core Data Structures
Python offers several built-in data structures that
are essential for organizing and managing data
efficiently. Understanding their characteristics is
crucial for effective programming.
Lists
Dictionaries
Sets
Tuples
Lists
Features: Ordered, mutable, can
contain mixed data types.
Syntax: square brackets [] .
Example : [1, 'a', 3]
Use case: Storing a sequence
where order matters and values
may change.
Tuples
Features: Ordered, immutable,
can contain mixed data types.
Syntax: parentheses ().
Example : (1, 'a', 3)
Use case: Grouping related
values that should not change.
Dictionaries
Features: Unordered (in older
Python versions), mutable, maps
unique keys to values.
Syntax: curly braces {} with key-
value pairs separated by colons.
Example : {'key': 42}
Use case: Fast lookup of values via
keys.
Sets
Features: Unordered, mutable,
holds unique elements only.
Syntax: curly braces {} without key-
value pairs.
Example : {1, 2, 3}
Use case: Removing duplicates,
performing set operations (union,
intersection).
Control Flow Statements
Control flow statements are fundamental to programming, allowing your
programs to make decisions and repeat actions based on specific conditions.
Conditional Statements
Looping Statements
if: Executes a block of code if a condition
is true. for: Iterates over a sequence (like a list,
elif (else if): Checks additional conditions tuple, or string).
if the preceding ones are false. while: Repeats a block of code as long
else: Executes a block of code if all as a condition is true.
preceding conditions are false.
Syntax(Conditional statements)
if statement: if-else statement:
elif statement:
EXAMPLE:
Syntax(Looping Statements)
for loop: while loop:
increment
EXAMPLE: EXAMPLE:
OOP’s in Python
Class 1
Object 2
Inheritance 3
Class Objects
In Python, a class serves as a
blueprint or a template for creating In Python, an object is a
objects. fundamental concept representing
It is a fundamental concept in object- a specific instance of a class.
oriented programming (OOP) which It is a collection of attributes
is a programming paradigm that (variables) and methods.
structures code around objects We use the object of a class to
rather than functions and logic. perform actions.
Using a class, you can create as many
SYNTAX:
objects as you want. object_name =
Class_name(arguments)
SYNTAX:
class Class_name
Example:
Inheritance
Inheritance in Python is a
fundamental concept of Object-
Oriented Programming (OOP)
It allows a new class (called the
child class, subclass, or derived
class) to inherit attributes and
methods from an existing class
(called the parent class, superclass,
or base class).
Thank You