Python is mainly built using keywords and built-in classes,Methods and functions, which handle most of the language behavior.




“Python uses a uniform object model where everything — including functions, classes, and even types — is an object with identity, type, and behavior.”

First: What is an object?
An object is:
-Stored in memory
-Has a type
-Has identity
-Has behavior (methods)
Python exposes all of these.

example:
x=10
type(x)          # int  #<class 'int'>
id(x)            # memory identity  #140734324569288
x.bit_length()   # method on a number!  #4



Parameter = a variable defined in a function or method definition
Argument = the actual value passed to a function when calling it
Attribute = a property or variable that belongs to an object

Term    Where it appearsWhat it is
ParameterFunction definition       Variable placeholder
Argument       Function call     Actual value
AttributeObject (obj.attr)     Property or method

1.Keywords (Language grammar)

These define how Python works.

Examples: if, else, for, while,def, class, return,try, except, finally,import, from, as,True, False, None

** They cannot be renamed or overridden.

2.Built-in Functions

These operate on objects or help interact with Python.

Examples: len(), type(), print(), range(), enumerate(), dir(), help()

Example:
len([1, 2, 3])   # calls list.__len__()

3.Built-in Classes (Data Types) & its Methods

These represent data and behavior.

Examples: int, float, str,list, tuple, set, dict

Everything is an object:
x = 10
x.__add__(5)   # same as 10 + 5

** Most Python operations are method calls on built-in classes.

4.External Liberary

#import
Rule of Thumb
Module → single Python file.
Package / Library → collection of modules.
When you do import X, you are importing a module or a package depending on what X is.

Python Environment
├── Built-in Modules (come with Python)
│   ├─ math.py          (module)
│   ├─ os.py            (module)
│   └─ sys.py           (module)
├── External Libraries / Packages (installed via pip)
│   ├─ requests/        (package)
│   │    ├─ __init__.py
│   │    ├─ models.py   (module)
│   │    └─ sessions.py (module)
│   ├─ numpy/           (package)
│   │    ├─ __init__.py
│   │    ├─ linalg.py   (module)
│   │    └─ random.py   (module)
│   └─ pandas/          (package)
│        ├─ __init__.py
│        └─ core.py     (module)
└── Your Own Files
     ├─ mymodule.py     (module)
     └─ mypackage/      (package)
          ├─ __init__.py
          └─ utils.py   (module)


Complete Python keyword list (Python 3.x)

----------
import keyword
print(dir(keyword))
print(keyword.kwlist)

['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'iskeyword', 'issoftkeyword', 'kwlist', 'softkwlist']
['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
-----------

1.Control flow            - if,elif,else,for,while,break,continue,pass
2.Logical operators       - and,or,not
3.Membership / identity   - in,is
4.Function & class        - def,return,lambda,yield,class
5.Exception handling      - try,except,finally,raise,assert
6.Imports & modules       - import,from,as
7.Context management      - with
8.Boolean & null          - True,False,None
9.Async / concurrency     - async,await
10.Variable scope         - global,nonlocal
11.Pattern matching       - match,case(Python 3.10+)


complete builtins functions


“In Python, functions perform actions, classes define blueprints for objects, and exceptions signal runtime errors that can be handled.”

builtins
├── functions → callable, not type           #A function is a reusable block of code that performs an action or returns a result.
├── classes   → instance of type             #A class is a blueprint used to create objects that hold data and behavior together
└── exceptions → subclass of BaseException   #An exception is an error that occurs while the program is running.

---------------------------------
import builtins

functions  = [n for n in dir(builtins) if callable(getattr(builtins,n)) and not isinstance(getattr(builtins,n),type)]   
classes    = [n for n in dir(builtins) if isinstance(getattr(builtins,n),type)]
exceptions = [n for n in classes if issubclass(getattr(builtins,n), BaseException)]

print(f'@@@ functions @@@\n {functions}')
print(f'@@@ classes @@@\n {classes}')
print(f'@@@ exceptions@@@\n {exceptions}')

@@@ functions @@@
 ['__build_class__', '__import__', 'abs', 'aiter', 'all', 'anext', 'any', 'ascii', 'bin', 'breakpoint', 'callable', 'chr', 'compile', 'copyright', 'credits', 'delattr', 'dir', 'divmod', 'eval', 'exec', 'exit', 'format', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'locals', 'max', 'min', 'next', 'oct', 'open', 'ord', 'pow', 'print', 'quit', 'repr', 'round', 'setattr', 'sorted', 'sum', 'vars']  
@@@ classes @@@
 ['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BaseExceptionGroup', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'EncodingWarning', 'EnvironmentError', 'Exception', 'ExceptionGroup', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'ModuleNotFoundError', 'NameError', 'NotADirectoryError', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError', 'PythonFinalizationError', 'RecursionError', 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopAsyncIteration', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TimeoutError', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '_IncompleteInputError', '__loader__', 'bool', 'bytearray', 'bytes', 'classmethod', 'complex', 'dict', 'enumerate', 'filter', 'float', 'frozenset', 'int', 'list', 'map', 'memoryview', 'object', 'property', 'range', 'reversed', 'set', 'slice', 'staticmethod', 'str', 'super', 'tuple', 'type', 'zip']
@@@ exceptions@@@
 ['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BaseExceptionGroup', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'EncodingWarning', 'EnvironmentError', 'Exception', 'ExceptionGroup', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'ModuleNotFoundError', 'NameError', 'NotADirectoryError', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError', 'PythonFinalizationError', 'RecursionError', 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopAsyncIteration', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TimeoutError', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '_IncompleteInputError']

---------------------------------------
import builtins
print(dir(builtins))
help(builtins .list)
help(builtins.print)
--------------------------------


Here is the Python built-in functions list (from builtins module), grouped so it’s easy to remember 


1.Type & Conversion Functions

int(),float(),complex(),str(),bool(),list(),tuple(),set(),frozenset(),dict()
bytes(),bytearray(),memoryview()

int, float, str, list, set, tuple, dict are built-in classes representing data types

Numeric Types - int, float, complex
Sequence Types - str, list-[], tuple-()
Set Types - set-{a,b}, frozenset
Mapping Type - dict-{}

** Hashing converts dictionary keys into hash values so data can be stored and retrieved in constant time 
d = {"name": "Mohan", "age": 30}
print(d["age"])   # very fast

how-it-works: 
1.You give a key: d["age"]
2.Python runs: hash("age")   # produces an integer
3.That hash decides where to store or find the value
4.Value is retrieved instantly

2.Iteration & Sequence Helpers

len(),range(),enumerate(),zip(),reversed(),sorted(),slice()
#zip()
keys = ['a', 'b', 'c']; values = [1, 2, 3];d = dict(zip(keys, values))
print(d) #{'a': 1, 'b': 2, 'c': 3}   #It walks side-by-side across iterables.
#slice()
s = "abcdefgh";sl = slice(1, 6, 2)
print(s[sl]) #'bfd'  start:stop:step

3.Math & Numeric Functions

abs(),round(),pow(),divmod(),sum(),min(),max()

nums = [-10, 5, 8, -3]
print(abs(min(nums)))   # 10
print(max(nums))        # 8
print(sum(nums))        # 0
print(divmod(17, 5))    # (3, 2)
print(round(3.14159, 2))# 3.14
print(pow(2, 4))        # 16

4.Logical / Comparison

all(), any()
all([A, B, C]) → A and B and C #True all([A, '', C]) #False
any([A, B, C]) → A or B or C #True

5.Type / Object Inspection

type(),id(),isinstance(),issubclass(),dir(),help(),vars(),callable()

6.Input / Output

input(),print()

7.Evaluation & Execution (⚠️ use carefully)

eval(),exec(),compile()

8.Attribute & Object Handling

getattr(),setattr(),hasattr(),delattr()

9.File & System Related
open()

10.ASCII / Unicode

ord(),chr(),ascii()

11.Miscellaneous

hash(),format(),repr(),bin(),oct(),hex(),breakpoint()



Think in 5 buckets:
Create data → int, str, list, dict
Loop → range, enumerate, zip
Check → type, isinstance, len
Calculate → sum, min, max
Debug → print, dir, help




---------------

                                  PART-2




Python string operations

split - based on separator [List]
partition - split into 3 equal value (tuple)
join
replace

list 
enumerate - index based calling
add element | remove element
merge list
extend

dictionary 
add element | remove element
merge dict
extend

checking
isinstance   >> verify its int, str, list, dict, set, tuple, etc

isinstance([1,2,3], list) → True
isinstance({"a":1}, dict) → True

Exception (error handling to avoid crash)
try,except,finally
raise

LOG-LEVELS
DEBUG < INFO < WARNING < ERROR < CRITICAL
Lower numbers = less severe, higher = more severe

Best practice:
DEBUG → development
INFO → normal operations
WARNING → recoverable issues
ERROR → failure in operation
CRITICAL → system failure, program may terminate

regular-expression
compile
search
finditer
non-capturing groups
look ahead | look behind


file-operations
open
read
write
readlines


Function (Paramenters,Arguments,retunvalue)

def sum(a,b):   #a,b -parameters
  retune a+b     #retun 
 sum(1,2)         #1,2 - arguments

print
return
yield
yield from
positional arguments
keyword arguments
*args
**args

Class  (obj.attribute) Anything you access using dot (.) notation is an attribute.
init method
other methods


## simple-example

class Car:     #1.Class definition -This creates a blueprint called Car.
    def __init__(self, brand): #2.Constructor  - Runs automatically when you create an object. 
        self.brand = brand #self.brand stores the brand name for each object.

    def drive(self): #3.Method - This is a behavior (function) that every Car object can use.
        print(f"{self.brand} is driving")
        
car1 = Car("Toyota")  #4.Object Creation  car1 → brand = "Toyota" car2 → brand = "BMW"   
car2 = Car("BMW")    #internally this happens > Car.__init__(car1, "Toyota" 

car1.drive(). #5.Calling Method
car2.drive()

#output

Toyota is driving
BMW is driving



----

Here’s a clean example showing multiple attributes being stored and then modified.


Example

class Car:
def __init__(self, brand, speed, color):
self.brand = brand # stored attribute
self.speed = speed # stored attribute
self.color = color # stored attribute

def accelerate(self, increase):
self.speed += increase # modifying attribute

def repaint(self, new_color):
self.color = new_color # modifying attribute

def show_details(self):
print(f"Brand: {self.brand}, Speed: {self.speed}, Color: {self.color}")

Using the class

car1 = Car("Toyota", 100, "Red")

car1.show_details()
# Brand: Toyota, Speed: 100, Color: Red

Modify attributes

car1.accelerate(20)
car1.repaint("Blue")

car1.show_details()
# Brand: Toyota, Speed: 120, Color: Blue

What’s happening

  • self.brand, self.speed, self.color → stored inside the object
  • Methods like accelerate() and repaint()change the object's state
  • Each object keeps its own independent data

Another object (independent)

car2 = Car("BMW", 150, "Black")
car2.show_details()
# Brand: BMW, Speed: 150, Color: Black

👉 car1 changes do NOT affect car2


Key idea

Objects are like containers:

  • Store data → attributes (self.x)
  • Change data → methods modify self.x

If you want next step, I can show:

  • class variables vs instance variables (very commonly asked in interviews)
  • or how this maps to real-world pytest test data usage