Skip to content

dracarys106/Python-and-its-data-structure-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 

Repository files navigation

Python-and-its-data-structure-

Detailed analysis of python as a programing language and its data structure

🐍 Python Complete Notes

Python is a high-level, interpreted, object-oriented, general-purpose programming language. It is popular for its simplicity, readability, and vast libraries.


πŸ”Ή 1. Features of Python

Simple & Easy β†’ Easy to learn and read.

Interpreted β†’ Executes line by line.

Cross-Platform β†’ Runs on Windows, Mac, Linux.

Object-Oriented β†’ Supports OOP concepts.

Dynamic Typing β†’ No need to declare variable types.

Huge Libraries β†’ Rich collection of built-in & external modules.


πŸ”Ή 2. Python Basics

2.1 Hello World

print("Hello, World!")

2.2 Variables & Data Types

x = 10 # int y = 3.14 # float name = "Utkarsh" # string is_active = True # boolean

2.3 Type Casting

a = int("5") # string to int b = str(123) # int to string c = float(4) # int to float

2.4 Input/Output

name = input("Enter your name: ") print("Hello,", name)


πŸ”Ή 3. Operators

Arithmetic: + - * / % ** //

Comparison: == != > < >= <=

Logical: and or not

Assignment: = += -= *= /=

Membership: in, not in

Identity: is, is not


πŸ”Ή 4. Conditional Statements

x = 20 if x > 10: print("Greater") elif x == 10: print("Equal") else: print("Smaller")


πŸ”Ή 5. Loops

For Loop

for i in range(5): print(i)

While Loop

n = 5 while n > 0: print(n) n -= 1

Loop Control

break β†’ exit loop

continue β†’ skip iteration

pass β†’ placeholder


πŸ”Ή 6. Functions

def add(a, b): return a + b

print(add(5, 10))

Default Arguments

def greet(name="User"): print("Hello", name)

Lambda Functions

square = lambda x: x * x print(square(5))


πŸ”Ή 7. Data Structures in Python

7.1 Lists

Ordered, mutable, allows duplicates.

fruits = ["apple", "banana", "cherry"] fruits.append("mango") fruits.remove("banana") print(fruits[0])

7.2 Tuples

Ordered, immutable, allows duplicates.

t = (1, 2, 3, 4) print(t[1])

7.3 Sets

Unordered, mutable, no duplicates.

s = {1, 2, 3, 3, 4} s.add(5) s.remove(2)

7.4 Dictionaries

Key-Value pairs, unordered, mutable.

student = {"name": "Utkarsh", "age": 20} print(student["name"]) student["age"] = 21


πŸ”Ή 8. Strings

s = "Hello Python" print(s.lower()) print(s.upper()) print(s.split()) print(s[0:5])

String Formatting:

name = "Utkarsh" age = 20 print(f"My name is {name} and I am {age} years old.")


πŸ”Ή 9. File Handling

Write to file

with open("test.txt", "w") as f: f.write("Hello World")

Read from file

with open("test.txt", "r") as f: data = f.read() print(data)


πŸ”Ή 10. Exception Handling

try: x = 10 / 0 except ZeroDivisionError: print("Division by zero error!") finally: print("Always executed")


πŸ”Ή 11. Object-Oriented Programming (OOP) in Python

class Car: def init(self, brand, speed): self.brand = brand self.speed = speed

def drive(self):
    print(f"{self.brand} is driving at {self.speed} km/h")

car1 = Car("Tesla", 120) car1.drive()

OOP Concepts

Encapsulation – using private variables (_var or __var)

Inheritance

class ElectricCar(Car): def init(self, brand, speed, battery): super().init(brand, speed) self.battery = battery

Polymorphism – method overriding

Abstraction – via abstract classes (abc module)


πŸ”Ή 12. Python Modules & Packages

import math print(math.sqrt(16))

Custom Module:

mymodule.py

def greet(name): return f"Hello {name}"

import mymodule print(mymodule.greet("Utkarsh"))

Popular Libraries:

NumPy β†’ Arrays & Math

Pandas β†’ Data Analysis

Matplotlib β†’ Visualization

Requests β†’ HTTP requests

Flask/Django β†’ Web frameworks


πŸ”Ή 13. Data Structures & Algorithms (DSA) in Python

Stack (LIFO)

stack = [] stack.append(1) stack.append(2) print(stack.pop())

Queue (FIFO)

from collections import deque queue = deque([1,2,3]) queue.append(4) print(queue.popleft())

Linked List (Implementation Example)

class Node: def init(self, data): self.data = data self.next = None

Trees & Graphs

Implemented using classes + recursion + adjacency lists.

Libraries: networkx (for graphs).


πŸ”Ή 14. Advanced Python Concepts

Generators & Iterators (yield)

Decorators (@decorator)

List Comprehensions

nums = [x**2 for x in range(5)]

Multithreading & Multiprocessing

Virtual Environments (venv)

Regular Expressions (re module)

About

Detailed analysis of python as a programing language and its data structure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published