Introduction to Python

Programming Language

A programming language is a way to tell a computer what to do. Just like you use English to talk to people, a programming language is used to give instructions to a computer.

Analogy:

Think of a programming language like a recipe. Just as a recipe gives step-by-step instructions to cook a dish, a programming language tells a computer exactly what to do. For instance, if you wanted to make tea:

  1. Boil water.
  2. Put tea leaves in a cup.
  3. Pour hot water into the cup.

A programming language is like writing these steps in a way the computer understands.

Examples: Python, Java, JavaScript, C, C++, etc.

Applications of Python

  • Web Application Development
  • Artificial Intelligence & Machine Learning
  • Data Analysis & Data Visualization
  • Automation & Scripting
  • Web Scraping
  • Scientific Computing
  • Game Development

Introduction to Python

Python is a high-level, general-purpose programming language known for its simple, readable syntax using indentation. It's widely used for web development, data analysis, AI, scripting, and automation due to its versatility and vast libraries/frameworks. Python prioritizes code readability and ease of learning.

Python software and its updates are maintained by a non-commercial organization called the "Python Software Foundation (PSF)"

Official Site: https://www.python.org/

Python Programming Language

History of Python

Python was developed by Guido van Rossum in the 1980s at the Centrum Wiskunde & Informatica (CWI) Institute in the Netherlands. Development started in 1989, but it was officially released in February 1991. Python was inspired by an older language called ABC, which Guido had worked on earlier. He wanted Python to be simpler and easier to use, making it popular for both beginners and experienced programmers.

Versions of python:
  1. Python 1.x — Here x: 1, 2, 3, 4, 5, 6.
  2. Python 2.x — Here x: 1, 2, 3, 4, 5, 6, 7 — outdated.
  3. Python 3.x — Here x: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ...
  4. Python 3.x does not contain backward compatibility with Python 2.x.

Features of Python

  1. Simple:
  2. Python is simple due to its rich libraries, automatic memory management, and user-friendly syntax. The libraries let developers reuse code, saving time and effort. Its garbage collector manages memory automatically, enhancing performance and reducing errors.

  3. Freeware and Open Source:
  4. Python is Freeware because it can be downloaded for free from its official website, www.python.org. It is also Open Source since its original version, CPython, can be modified and customized for various needs, leading to different Python distributions. Examples: Jython, IronPython, MicroPython, PyPy etc.

  5. Platform Independent:
  6. Python is Platform Independent because its programs can run on any operating system. In Python, all values are stored as objects, making them independent of the underlying OS. This ensures seamless execution across different platforms like Windows, macOS, and Linux.

  7. Dynamically Typed:
  8. Python is a dynamically typed programming language because variables do not require explicit type declarations; the interpreter assigns the type at runtime. It automatically determines the data type based on the assigned value. All values in Python are stored as objects, with classes working behind the scenes to define their behavior. This makes coding simpler and more flexible.

  9. Interpreted Language:
  10. Python is an Interpreted Programming Language because its code is executed line by line. First, the Compilation Process checks for syntax errors and converts the code into an intermediate form called Byte Code (.pyc) if no errors are found. Then, the Execution Process uses the Python Virtual Machine (PVM) to interpret this byte code into machine code line by line. This makes Python easier to debug and more flexible for development.

  11. Supports Third-Party APIs:
  12. Python supports powerful third-party APIs like NumPy, Pandas, Matplotlib, SciPy, and Scikit, which enhance project efficiency. These libraries simplify data analysis, visualization, and scientific computing. To use them, you can easily install them with tools like Pip Installs Packages (PIP).

Exercise

  1. Fill in the Blanks:
    • - Python was developed by __________ and officially released in the year __________.
    • - Python is a __________ language because variable types are determined at runtime.
    • - The non-commercial organization maintaining Python is called the __________.
    • - A popular Python library for numerical computing, mentioned in the text, is __________.
    • - Python code is executed __________ by the Python interpreter.