Week #1 "What is the evolutionary history of the Python?" '+' #' Basics'/n'
Overview 2.2 DR Cones

Week #1 "What is the evolutionary history of the Python?" '+' #' Basics'/n'

Background of Python:

Origin: Python, created by Guido van Rossum, emerged in the late 1980s as a side project to address shortcomings in the ABC language. In February 1991, Python version 0.9.0 was released. The language's name was inspired by the British comedy group Monty Python, showing Guido's appreciation for their humor. Python's development continued, and in 2000, Python 2.0 was released, introducing features like garbage collection and Unicode support.

- Philosophy: Python emphasizes readability, simplicity, and explicitness in code. This is often summarized as "The Zen of Python," which you can view by typing import this into a Python interpreter. Some key principles include "Readability counts" and "Simple is better than complex."        

Design: Python is designed to be versatile and flexible, allowing developers to accomplish tasks with fewer lines of code compared to other languages. It supports multiple programming paradigms, including procedural, object-oriented, and functional programming.

  • Interpreted Language: Python is an interpreted language, meaning the source code is executed line by line by an interpreter, rather than being compiled into machine code before execution. This makes development and debugging easier, as you can see immediate results.

  • Open Source: Python is open source, which means its source code is freely available for anyone to use, modify, and distribute. This has contributed to its widespread adoption and vibrant community of developers contributing to its growth.

The programming language Python was conceived in the late 1980s, and its implementation was started in December 1989 by Guido van Rossum at CWI in the Netherlands as a successor to ABC capable of exception handling and interfacing with the Amoeba operating system.
The programming language Python was conceived in the late 1980s, and its implementation was started in December 1989 by Guido van Rossum at CWI in the Netherlands as a successor to ABC capable of exception handling and interfacing with the Amoeba operating system.
Python's popularity soared due to its simplicity, readability, and versatility. It gained traction in various fields, including web development, scientific computing, data analysis, and automation. In 2008, Python 3.0 was released, aiming to address inconsistencies and improve the language's design. However, the transition from Python 2 to Python 3 was gradual due to compatibility issues, with Python 2 finally reaching its end of life in January 2020.        
Tabular Formate.

Evolution of Python:

Python 2 vs. Python 3: In 2008, Python 3 was released as the successor to Python 2. Python 3 introduced several improvements and new features while addressing some of the shortcomings of Python 2. However, due to differences in syntax and functionality, Python 2 code is not always compatible with Python 3.

Given below is a timeline of the release of the various versions of the Python 3.X series:        

  • Python 3.0 – December 3, 2008
  • Python 3.1 – June 27, 2009
  • Python 3.2 – February 20, 2011
  • Python 3.3 – September 29, 2012
  • Python 3.4-March 16, 2014
  • Python 3.5 – September 13, 2015
  • Python 3.6- October 2016
  • Python 3.7- June 2018.

Python 2

def main():
  print "Hi! This is Python 2"
  
if __name__== "__main__":
  main()        

Python 3

def main():
  print ("Hi! This is Python 3")
  
if __name__== "__main__":
  main()        
Difference Between Python 2 and 3


  1. Community and Ecosystem: Python has a vast ecosystem of libraries and frameworks built by its community. These include tools for web development (Django, Flask), scientific computing (NumPy, SciPy), machine learning (TensorFlow, PyTorch), and more. The Python Package Index (PyPI) hosts thousands of third-party packages that can be easily installed using the pip package manager.
  2. Performance Improvements: Python's performance has steadily improved over the years, thanks to optimizations in the interpreter and advancements in hardware. Additionally, projects like PyPy and Cython offer alternative Python interpreters and compilers that can improve execution speed for certain types of code.
  3. Current State: Today, Python is one of the most widely used programming languages worldwide, renowned for its ease of learning, extensive standard library, and vibrant ecosystem of third-party packages. Its simplicity makes it accessible to beginners, while its power and flexibility attract seasoned developers. Python's popularity in data science and machine learning, fueled by libraries like NumPy, Pandas, Scikit-learn, and TensorFlow, has cemented its position as a leading language in these domains.

Python's web frameworks, such as Django and Flask, enable rapid development of web applications, while its scripting capabilities make it invaluable for automation and system administration tasks. Additionally, Python's cross-platform compatibility allows code written in Python to run seamlessly on various operating systems, further enhancing its appeal.        

  • Python's influence extends beyond programming. It's used in education to teach computational thinking and problem-solving skills. Its role in scientific research, finance, and entertainment underscores its versatility and ubiquity.

"Important Information:- noted"

Python has a rich ecosystem of libraries and frameworks across various fields, making it versatile and suitable for a wide range of applications.         

Here's an overview of some popular libraries and the fields they are commonly used in:

Some popular libraries and the fields they are commonly.....

Web Development:

  1. Django: A high-level web framework that encourages rapid development and clean, pragmatic design. It's used for building robust and scalable web applications.
  2. Flask: A lightweight web framework that's easy to learn and quick to get started with. It's commonly used for building small to medium-sized web applications and APIs.

Data Science and Machine Learning:

  1. NumPy: A fundamental package for numerical computing with Python. It provides support for large, multi-dimensional arrays and matrices, along with a collection of mathematical functions to operate on these arrays.
  2. Pandas: A powerful library for data manipulation and analysis. It provides data structures like DataFrame, which makes working with structured data easy and intuitive.
  3. Matplotlib: A plotting library for creating static, interactive, and animated visualizations in Python. It's commonly used for data visualization and exploration.
  4. Scikit-learn: A machine learning library that provides simple and efficient tools for data mining and data analysis. It includes various algorithms for classification, regression, clustering, and dimensionality reduction.
  5. TensorFlow: An open-source machine learning framework developed by Google. It's used for building and training deep learning models, including neural networks, convolutional networks, and recurrent networks.
  6. PyTorch: An open-source machine learning library developed by Facebook. It's known for its dynamic computation graph and is widely used for building deep learning models, especially in research settings.

Natural Language Processing (NLP):

  1. NLTK (Natural Language Toolkit): A leading platform for building Python programs to work with human language data. It provides easy-to-use interfaces to over 50 corpora and lexical resources.
  2. spaCy: An open-source library for advanced Natural Language Processing (NLP) in Python. It's designed to be fast, efficient, and easy to use, with support for various NLP tasks such as tokenization, part-of-speech tagging, named entity recognition, and dependency parsing.

Web Scraping and Crawling:

  1. Beautiful Soup: A library for pulling data out of HTML and XML files. It provides simple methods and Pythonic idioms for navigating, searching, and modifying parsed tree structures.
  2. Scrapy: A fast, high-level web crawling and web scraping framework. It provides a clean and simple API for extracting data from websites and saving it to various formats.

GUI Development:

  1. Tkinter: The standard GUI toolkit for Python. It's included with most Python installations and provides a simple way to create desktop applications with a graphical user interface.
  2. PyQt / PySide: Python bindings for the Qt application framework. They allow Python programmers to create cross-platform applications with a native look and feel.

Game Development:

  1. Pygame: A set of Python modules designed for writing video games. It provides functionality for handling graphics, sound, and user input, making it suitable for both 2D and simple 3D game development.

Web Scraping and Crawling:

  1. Beautiful Soup: A library for pulling data out of HTML and XML files. It provides simple methods and Pythonic idioms for navigating, searching, and modifying parsed tree structures.
  2. Scrapy: A fast, high-level web crawling and web scraping framework. It provides a clean and simple API for extracting data from websites and saving it to various formats.

Testing and Quality Assurance:

  1. unittest: The built-in unit testing framework in Python. It's part of the standard library and provides a way to write and execute tests for your code.
  2. pytest: A popular testing framework that extends unittest and provides additional features like automatic test discovery, fixtures, and parameterized testing.

Other Popular Libraries:

  1. Requests: A simple yet powerful HTTP library for making HTTP requests in Python. It's widely used for interacting with web APIs and fetching data from web servers.
  2. OpenCV: An open-source computer vision library that provides tools for image and video analysis, object detection, and machine learning.

Top Python Libraries To Know in 2024

Step -1 "Installing Python:- In Your Set up.

  1. Download Python: Go to the official Python website at https://www.python.org/ and download the latest version of Python. Make sure to select the appropriate installer for your operating system (Windows, macOS, or Linux).
  2. Install Python: Once the download is complete, run the installer and follow the installation instructions. Make sure to check the box that says "Add Python to PATH" during the installation process. This will allow you to run Python from the command line easily.
  3. Verify Installation: After the installation is complete, open a command prompt (Windows) or terminal (macOS/Linux) and type python --version or python3 --version and press Enter. You should see the version number of the Python interpreter you installed.

You can run as well in other Plateform Such as ( Replit is an AI-driven software creation platform where everyone can build, share, and ship software fast.)

Getting Started with Python: ( "Please ignored some things if you dont know for now")

  1. Hello, World!: Let's start with the classic "Hello, World!" program. Open a text editor and type the following:

print("Hello, World!")        

Out put Below

print("Hello, World!")

Save the file with a '.py' extension, for example, 'hello.py.' Then, open a command prompt or terminal, navigate to the directory where you saved the file, and type python hello.py to run the program. You should see "Hello, World!" printed to the console.

  1. Variables and Data Types: Python is dynamically typed, meaning you don't need to declare the type of a variable before assigning a value to it. Here's an example:

# Variables and Data Types
name = "John"   # string
age = 30        # integer
height = 5.9    # float
is_student = True  # boolean        
https://www.theengineeringprojects.com/2020/06/how-to-use-data-types-in-python.html

Out put Below

# Variables and Data

Types name = "John" # string

age = 30 # integer

height = 5.9 # float

is_student = True # boolean

  1. Comments: Comments in Python start with the # symbol. They are used to explain the code and are ignored by the Python interpreter.

# This is a comment # Comments are ignored by the interpreter

  1. Basic Arithmetic: Python can be used as a calculator. You can perform arithmetic operations like addition, subtraction, multiplication, and division.

# Basic Arithmetic
result = 10 + 5   # addition
result = 10 - 5   # subtraction
result = 10 * 5   # multiplication
result = 10 / 5   # division        

# Basic Arithmetic

result = 10 + 5 # addition

result = 10 - 5 # subtraction

result = 10 * 5 # multiplication

result = 10 / 5 # division

'<Some Basic Arithmetic which you see next to post>'

"Internal" and "external" Python typically refer to different aspects of the Python environment and ecosystem.

4.32 Onw way

Internal Python:

  1. Built-in Modules: These are modules that are part of the Python standard library. They come pre-installed with Python and provide core functionality for tasks such as file I/O, string manipulation, mathematical operations, etc. Examples include os, sys, math, datetime, etc.
  2. Language Features: Internal to Python are its language features, syntax, and constructs. These include concepts like functions, classes, modules, iterators, generators, decorators, and more. They form the core of the Python programming language and are available in every Python environment.

External Python:

  1. Third-Party Libraries: External Python refers to libraries and packages that are not part of the Python standard library. These are developed by third-party developers and community members to extend Python's capabilities beyond its built-in functionality. Examples include libraries for data analysis (Pandas, NumPy), web development (Django, Flask), machine learning (TensorFlow, PyTorch), and more.
  2. Virtual Environments: While not exactly "external" in the traditional sense, virtual environments are isolated Python environments that allow you to install and manage packages separately from the system-wide Python installation. Tools like virtualenv and venv are commonly used to create and manage virtual environments, ensuring that dependencies for different projects remain isolated and don't interfere with each other.

In Python, a module is a file containing Python code. The code can define functions, classes, variables, or even executable code that can be reused in other Python programs. Modules help organize and structure code into logical units, making it easier to manage and maintain large projects.

Here's a breakdown of modules in Python:

Creating Modules:

Google 3.2

To create a module, you simply create a Python file with a .py extension and write your code inside it. For example, let's create a module named my_module.py:

# my_module.py
def greet(name):
    print("Hello, " + name + "!")        

Using Modules:

Once you've created a module, you can use it in other Python scripts by importing it. For example:

# main.py
import my_module
my_module.greet("Alice")        

Module Attributes:

Modules can contain variables, functions, and classes that can be accessed using dot notation. For example, if my_module.py contains a variable PI:

# my_module.py
PI = 3.14159        

You can access it in another script like this:

# main.py
import my_module
print(my_module.PI)        

Module Search Path:

When you import a module, Python searches for it in a list of directories known as the module search path. This path includes the directory containing the script being executed and the directories listed in the PYTHONPATH environment variable.

Pathway on 3'py'/n'

Standard Library Modules:

Python comes with a rich set of standard library modules that provide additional functionality for common tasks such as file I/O, networking, data manipulation, and more. You can import these modules in your scripts just like any other module. For example:

import os
import random
import datetime        

Third-Party Modules:

In addition to the standard library, Python has a vast ecosystem of third-party modules available for various purposes. These modules can be installed using package managers like pip and imported into your scripts as needed.

'pip' (Python Package Installer):

pip is the package installer for Python. It's a command-line tool that allows you to install, upgrade, and manage Python packages from the Python Package Index (PyPI) and other package repositories.

Installing Packages with pip:

You can install packages using pip by running the following command in your terminal or command prompt:

pip install package_name        

For example, to install the requests package:

pip install requests        

Managing Packages:

4.6 hty Google

pip also allows you to manage packages, including upgrading and uninstalling them. For example:

  • To upgrade a package:
  • To uninstall a package:

Python Types:

Python is a dynamically-typed language, meaning you don't need to explicitly declare the data type of a variable. Python has several built-in data types, including:

  • Numeric Types: Integers (int), Floating-point numbers (float), and Complex numbers (complex).
  • Sequence Types: Lists (list), Tuples (tuple), and Strings (str).
  • Mapping Types: Dictionaries (dict).
  • Set Types: Sets (set) and Frozen sets (frozenset).
  • Boolean Type: Boolean (bool).
  • None Type: None (NoneType), which represents the absence of a value.

Python also supports custom data types through classes and objects.

Reference:-

Downey, A. B. (2015). Think Python: How to Think Like a Computer Scientist (2nd Edition). O'Reilly Media.

Lutz, M. (2013). Learning Python (5th Edition). O'Reilly Media.

Sweigart, A. (2015). Automate the Boring Stuff with Python: Practical Programming for Total Beginners. No Starch Press.

Beazley, D. M. (2009). Python Essential Reference (4th Edition). Addison-Wesley Professional.

Pilgrim, M. (2004). Dive Into Python. Apress.

Guttag, J. V. (2016). Introduction to Computation and Programming Using Python: With Application to Understanding Data. MIT Press.

McKinney, W. (2017). Python for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython (2nd Edition). O'Reilly Media.

VanderPlas, J. (2016). Python Data Science Handbook: Essential Tools for Working with Data. O'Reilly Media.

Beazley, D. M. (2009). Python Cookbook (3rd Edition). O'Reilly Media.

Ramalho, L. (2015). Fluent Python: Clear, Concise, and Effective Programming. O'Reilly Media.

Van Rossum, G., & Drake, F. L. (2009). Python 3 Reference Manual. CreateSpace.

Django Documentation: https://docs.djangoproject.com/en/stable/

Flask Documentation: https://flask.palletsprojects.com/en/stable/

NumPy Documentation: https://numpy.org/doc/

Pandas Documentation: https://pandas.pydata.org/docs/

Matplotlib Documentation: https://matplotlib.org/stable/contents.html

SciPy Documentation: https://docs.scipy.org/doc/

Scikit-learn Documentation: https://scikit-learn.org/stable/documentation.html

TensorFlow Documentation: https://www.tensorflow.org/guide

Python Official Documentation: https://docs.python.org/3/

要查看或添加评论,请登录

Satender Kumar的更多文章

社区洞察

其他会员也浏览了