[go: up one dir, main page]

0% found this document useful (0 votes)
5 views15 pages

Python Programming DBATU

This document provides an overview of Python programming, highlighting its features, uses, and basic structure. It covers Python's applications in various fields such as AI, data science, and web development, as well as its internal workings and basic building blocks. Additionally, it outlines Python's operators, data types, and includes examples of small Python programs.

Uploaded by

dapkepranam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views15 pages

Python Programming DBATU

This document provides an overview of Python programming, highlighting its features, uses, and basic structure. It covers Python's applications in various fields such as AI, data science, and web development, as well as its internal workings and basic building blocks. Additionally, it outlines Python's operators, data types, and includes examples of small Python programs.

Uploaded by

dapkepranam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Python Programming Basics

DBATU Diploma Notes - PPT


Introduction to Python
Programming

• Python = High-level, interpreted, general-


purpose programming language
• Created by Guido van Rossum (1989), released
in 1991
• Philosophy = Code readability & simplicity
• Beginner friendly + Powerful for advanced
users
Features of Python

• Easy to Learn & Readable → Simple syntax like


English
• Interpreted Language → Executes line by line
• Object-Oriented → Supports classes, objects,
inheritance, polymorphism
• Cross-Platform → Runs on Windows, Linux,
Mac
• Extensive Libraries → NumPy, Pandas,
Matplotlib, etc.
Where is Python Used?

• AI & ML → TensorFlow, PyTorch


• Data Science → Pandas, NumPy, Matplotlib
• Web Development → Django, Flask
• Automation / Scripting → Repetitive tasks
automation
• Game Development → Pygame
• Cyber Security → Ethical hacking tools
• IoT & Embedded Systems → MicroPython,
Python Frameworks & Libraries

• Web Development → Django, Flask


• GUI → Tkinter, PyQt
• Data Science → NumPy, Pandas, Matplotlib
• AI/ML → TensorFlow, scikit-learn, PyTorch
Python Virtual Machine (PVM)

• Runtime engine that executes Python


bytecode
• Converts bytecode → machine code
• Components: Runtime Engine, Runtime
Environment
• Frozen Binaries → Python program bundled
with PVM for easy execution
Typical Python Program Structure

• Documentation (comments/docstrings)
• Import (modules/libraries)
• Global Section (constants, global vars)
• Class Section (class definitions)
• Subprograms (functions)
• Playground/Main (main logic)
Python Implementations &
Distributions

• Implementations: CPython, Jython,


IronPython, PyPy, Stackless, MicroPython
• Distributions: Anaconda, Canopy,
PythonAnywhere, WinPython
Internal Working of Python

• Python Source Code → Compiler → Bytecode


• Bytecode executed by Python Virtual Machine
(PVM)
• Interpreter inside PVM → Machine code
execution
Basic Building Blocks of Python

• Identifiers → Names for variables/functions


• Keywords → Predefined reserved words
• Variables → Store values (dynamically typed)
• Indentation → Defines code blocks (no braces
{})
• Comments → Single-line (#), Multi-line ("""
""")
Literals in Python

• Numeric → int, float, complex


• String → Single/double/triple quotes
• Boolean → True / False
• Special → None
• Collections → List, Tuple, Dict, Set literals
Data Types & String Operations

• Data Types: int, float, complex, bool, str, list,


tuple, dict, set
• String operations:
• Indexing → s[0]
• Slicing → s[1:4]
• Methods → split(), join(), upper(), lower()
Input and Output

• Input → input() function (always returns


string)
• Output → print() function with sep, end, file,
flush parameters
Operators in Python

• Arithmetic (+, -, *, /, %, //, **)


• Assignment (=, +=, -=, *=, etc.)
• Relational (==, !=, >, <, >=, <=)
• Logical (and, or, not)
• Bitwise (&, |, ^, ~, <<, >>)
• Identity (is, is not)
• Membership (in, not in)
• Operator precedence & associativity define
Small Python Programs

• Square root of number → num ** 0.5


• Area of rectangle → l * b
• Area & Perimeter of square → a*a, 4*a
• Surface area & volume of cylinder → 2πrh +
2πr², πr²h
• Swap two variables → x, y = y, x

You might also like