PYTHON / DJANGO
PYTHON
• High level
• Interpreted Language
• Object oriented
• Dynamically typed
• Multi-Paradigm
• Open Source and Free
• Scalable and Extensible
High Level
• Python is close to human language,
• not machine language.
• don’t have to manage memory or hardware details.
• Example
print(“helllllo Universeee”)
Interpreted Language
• Python code is executed line by line.
• No need to compile before running.
• Errors are shown immediately.
• Code → Interpreter → Output
Object-Oriented
• Python supports classes and objects
• Helps organize large programs into reusable components.
• Follows OOP concepts:
• Encapsulation
• Inheritance
• Polymorphism
• Abstraction
• Example
class Student:
def __init__(self, name):
self.name = name
Dynamically Typed
• No need to declare variable types.
• DataType is decided at runtime.
• Example
x = 10 # integer
x = "AI" # string
Multi-Paradigm
Python supports multiple programming styles:
• Procedural
print("Hello")
• Object-Oriented
class Car:
pass
• Functional
numbers = [1, 2, 3]
result = list(map(lambda x: x*2, numbers))
Open Source and Free
• Python is free to use, modify, and distribute.
• Source code is publicly available.
• Supported by a large global community.
• No license cost for individuals or companies.
Scalable
• Can grow with project size.
• Used by companies like Google, Netflix, and Instagram.
• Python works for:
• Small scripts
• Medium applications
• Large enterprise systems
Extensible
• Python can integrate with:
• C / C++
• Java
• Databases
• APIs
• Performance-critical parts can be written in faster languages.
Important terms to know
• Function - A function is a reusable block of code that performs a specific
task.
• Module - A module is a single Python file (.py) that contains functions,
variables, or classes.
• Library - A library is a collection of modules that provide related
functionality.
• Package - A package is a collection of modules organized in folders.
• Class - A class is a blueprint for creating objects. It defines variables and methods.
• Object - An object is a real instance of a class. It represents real-world entities and
contains data (variables) and behavior (methods).
• Keyword - they are reserved words with predefined meaning in Python.
• Indentation - defines code blocks instead of { }.
• Namespace - is a container that holds variable names and their values.
• Scope - defines where a variable can be accessed.
• Generator - produces values one at a time using yield.
DJANGO
• Django is a high-level Python web framework used to build secure,
scalable, and maintainable web applications quickly.
• Django helps you build backend web applications without reinventing
the wheel.
WHY DJANGO
• Fast development – lots of built-in features
• Secure by default – protects against common attacks
• Follows best practices – clean, organized code
• Batteries included – admin panel, ORM, auth, forms
• Used by big companies (Instagram, Pinterest, Mozilla)
M V T DESIGN PATTERN
• Model - The data you want to present, usually data from a database.
• View - A request handler that returns the relevant template and
content - based on the request from the user
• Template - A text file (like an HTML file) containing the layout of the
web page, with logic on how to display the data.
Component Role Easy Meaning
Model Database logic Tables & data
View Business logic Brain of app
Template UI HTML pages
• Django receives the URL, checks the urls.py file, and calls the view that
matches the URL.
• The view, located in views.py, checks for relevant models.
• The models are imported from the models.py file.
• The view then sends the data to a specified template in
the template folder.
• The template contains HTML and Django tags, and with the data it
returns finished HTML content back to the browser.
python - A basic notes for beginners(newbies)
python - A basic notes for beginners(newbies)
python - A basic notes for beginners(newbies)
python - A basic notes for beginners(newbies)
python - A basic notes for beginners(newbies)
python - A basic notes for beginners(newbies)