Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Python Practical 1

Uploaded by

vrajpatel.2060
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Python Practical 1

Uploaded by

vrajpatel.2060
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

History of Python
●​ Created by: Guido van Rossum in 1989, officially released in 1991.
●​ Developed as a successor to the ABC programming language, with an emphasis on
simplicity and extensibility.
●​ Open-source and community-driven, maintained by the Python Software
Foundation.
●​ Key milestones:
○​ Python 1.0 (1994) – First official release.
○​ Python 2.0 (2000) – Introduced garbage collection and list comprehensions.
○​ Python 3.0 (2008) – Major changes for better Unicode support and modern
features.
○​ Python 3.x updates – Continuous improvements with better performance and
features.

2. Compiler vs. Interpreter

Compiler

●​ Translates the entire source code into machine code before execution.
●​ Faster execution as the program runs in machine language.
●​ Errors are displayed after compilation.
●​ Examples: C, C++, Java (JIT Compilation), Go.

Interpreter

●​ Translates code line-by-line at runtime.


●​ Slower than a compiler but easier to debug.
●​ Errors are displayed immediately during execution.
●​ Examples: Python, JavaScript, Ruby, PHP.

Python uses an interpreter called CPython but also supports JIT compilation in PyPy.
3. Applications of Python
Python is used in almost every field:

✔ Web Development

●​ Frameworks: Django, Flask, FastAPI


●​ Example: Instagram, Spotify use Django.

✔ Data Science & Machine Learning

●​ Libraries: NumPy, Pandas, Matplotlib, Scikit-learn, TensorFlow, PyTorch


●​ Used for: Data analysis, AI, deep learning.

✔ Game Development

●​ Library: Pygame
●​ Example: Civilization IV used Python for AI scripting.

✔ Automation & Scripting

●​ Automates repetitive tasks (e.g., file handling, web scraping).


●​ Libraries: Selenium, BeautifulSoup, PyAutoGUI

✔ Embedded Systems & IoT

●​ Used in Raspberry Pi projects.


●​ MicroPython for IoT applications.

✔ Desktop & GUI Applications

●​ Libraries: PyQt, Tkinter, Kivy


●​ Used to build cross-platform applications.

4. Python Versions

Version Release Year Key Features

Python 1.0 1994 First official release


Python 2.0 2000 List comprehensions, garbage collection

Python 3.0 2008 Unicode support, better syntax

Python 3.6 2016 F-strings, type hints

Python 3.9 2020 Dictionary merge & update operators

Python 3.11 2022 Faster performance improvements

5. Popular Python IDEs

IDE

PyCharm

VS Code

Jupyter Notebook

IDLE

Spyder

Thonny

6. Features of Python

​ Simple & Readable Syntax:

●​ Python syntax is close to English, making it easy to learn.

●​ Compared to other languages like Java or C++, Python requires less code to
achieve the same result.

Interpreted Language:

●​ Python does not need compilation like C or Java.


●​ Code is executed line-by-line, making debugging easier.
●​ Python uses the CPython interpreter by default.

Dynamically Typed

●​ No need to declare variable types (int, float, string, etc.).


●​

x = 10 # x is an integer
x = "Hello" # x is now a string (no error)

●​ This makes Python more flexible but can lead to runtime errors if not managed
properly.

Object-Oriented & Procedural Support

●​ Python supports both:​


✔ Procedural programming – Using functions.​
✔ Object-Oriented programming (OOP) – Using classes and objects.
●​

Cross-Platform Compatibility

●​ Python code runs on Windows, macOS, Linux, and even mobile devices.
●​ Write code once, run it anywhere (WORA – Write Once, Run Anywhere).

Large Standard Library

●​ Python has built-in modules for different tasks like:​


✔ File handling (os, shutil)​
✔ Web development (Flask, Django)​
✔ Data analysis (Pandas, NumPy)​
✔ Machine learning (TensorFlow, Scikit-learn)​
✔ GUI programming (Tkinter, PyQt)

Memory Management (Garbage Collection)

●​ Python has automatic memory management using garbage collection.


●​ Objects that are no longer in use are automatically deleted to free up memory.

Web Development Support

●​ Python is widely used in web development with frameworks like:​


✔ Django (Full-featured, secure)​
✔ Flask (Lightweight, flexible)​
✔ FastAPI (For high-performance APIs)
Data Science & Machine Learning

●​ Python is the most popular language for AI & ML due to libraries like:​
✔ NumPy (Numerical computing)​
✔ Pandas (Data analysis)​
✔ Matplotlib & Seaborn (Data visualization)​
✔ Scikit-learn (Machine learning)​
✔ TensorFlow & PyTorch (Deep learning)

7. Advantages of Python Over Other Languages


✅ Readable & Simple Syntax – Easier than C, Java.​
✅ Faster Development – Less code, quicker debugging.​
✅ Huge Libraries & Frameworks – Supports AI, ML, web, etc.​
✅ Platform-Independent – Write once, run anywhere.​
✅ Great for Rapid Prototyping – Quick idea validation.​
✅ Community Support – Large online resources.​
✅ Used by Top Companies – Google, Facebook, NASA, Netflix.
8.Dynamic Typing (Python, JavaScript, Ruby)

✔ No need to declare variable types.​


✔ More flexibility but can cause runtime errors.

x = 10 # Integer

x = "Hello" # Now it's a string

Static Typing (C, Java, Go)

✔ Variables have fixed types.​


✔ Less flexible but safer.

int x = 10; // Only an integer

x = "Hello"; // Error: Type mismatch

9. Procedural vs. Object-Oriented Programming

📌 Procedural Programming
●​ Definition: Follows a step-by-step procedure (sequence of functions).
●​ Focus: On functions rather than data.
●​ Data Handling: Separate from functions.
●​ Security: Less secure, as data is accessible globally.
●​ Code Reusability: Harder to reuse code.
●​ Example Languages: C, Pascal, Python (supports both).

📌 Object-Oriented Programming (OOP)


●​ Definition: Uses objects and classes to organize code.
●​ Focus: On data (objects) rather than functions.
●​ Data Handling: Encapsulated inside objects.
●​ Security: More secure using Encapsulation.
●​ Code Reusability: Supports code reuse through Inheritance & Polymorphism.
●​ Example Languages: Python, Java, C++.

You might also like