0% found this document useful (0 votes)
3 views23 pages

03.Overview of Python Programming

The document provides an overview of Python programming, highlighting its high-level, interpreted nature, extensive libraries, and versatility for various applications. It covers the history of Python, major releases, and its growing popularity, as well as features like readability, dynamic typing, and cross-platform compatibility. Additionally, it discusses Python components, IDEs, and its use as a calculator, emphasizing its role in scientific computing and real-time debugging through the Python Shell.

Uploaded by

ganpatikrathia
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)
3 views23 pages

03.Overview of Python Programming

The document provides an overview of Python programming, highlighting its high-level, interpreted nature, extensive libraries, and versatility for various applications. It covers the history of Python, major releases, and its growing popularity, as well as features like readability, dynamic typing, and cross-platform compatibility. Additionally, it discusses Python components, IDEs, and its use as a calculator, emphasizing its role in scientific computing and real-time debugging through the Python Shell.

Uploaded by

ganpatikrathia
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/ 23

Overview of Python

Programming
Ganpati Rathia
Assistant Professor
CEA Dept
GLA University
Introduction to Python
• High-level, Interpreted Language: Python is easy to read and write,
abstracting many complexities.
• General-purpose: Used for web development, data science, AI,
automation, and more.
• Open-source & Cross-platform: Available on multiple platforms with
a large community of developers.
• Simple Syntax: Python's syntax emphasizes readability, reducing the
cost of program maintenance.
• Extensive Libraries: Offers powerful libraries for scientific computing
(NumPy, Pandas), web frameworks (Django, Flask), and machine
learning (TensorFlow, scikit-learn).
• Popular for Beginners & Experts: Ideal for beginners due to its
simplicity, but also powerful enough for professional development.
History of Python Programming
Python is a high-level, interpreted programming language
that was created by Guido van Rossum and first released in
1991. The language was designed to emphasize code
readability and simplicity, making it accessible to both
beginners and experienced developers.
• Early Development (Late 1980s - 1991)
• Python's development began in the late 1980s at Centrum
Wiskunde & Informatica (CWI) in the Netherlands. Guido van
Rossum, inspired by the ABC programming language, aimed to
create a language that addressed its shortcomings while
retaining its ease of use. Python 1.0 was officially released on
February 20, 1991.
History of Python Programming
(Cont…)
• Major Python Releases
• Python 1.x (1991 - 2000): Introduced fundamental features
such as exception handling, functions, and core data types
(lists, dictionaries, strings, etc.).
• Python 2.x (2000 - 2010): Brought major improvements,
including list comprehensions and garbage collection. However,
it had inconsistencies that led to the development of Python 3.
• Python 3.x (2008 - Present): Introduced major changes,
making the language more consistent and efficient. Key
improvements included better Unicode support, improved
standard libraries, and enhanced performance.
• Python's Growth and Popularity
Python has gained immense popularity over the years due to its versatility.
It is widely used in web development, data science, artificial intelligence,
automation, and scientific computing. Its strong community support and
extensive libraries contribute to its success.

• Current State and Future of Python


Python continues to evolve with regular updates and enhancements. The
latest versions focus on performance improvements, type hints, and better
concurrency support. With the rise of machine learning, artificial
intelligence, and cloud computing, Python remains one of the most in-
demand programming languages globally.

• Python’s simplicity and adaptability ensure that it will continue to


be a dominant force in the programming world for years to come.
Features of Python Programming
• Readable and Simple Syntax: Python emphasizes
readability and simplicity, making it easy to write and
understand.
• Interpreted Language: Python code is executed line-by-
line, which makes debugging easier and faster.
• Dynamically Typed: Variables don’t require an explicit
declaration of data types.
• High-level Language: Python abstracts low-level
operations, allowing developers to focus on logic rather than
memory management.
• Extensive Standard Library: A rich set of modules and
libraries for tasks like file I/O, web development, data
manipulation, and more.
Features of Python Programming
(Cont…)
• Cross-platform: Python code runs on various platforms
(Windows, macOS, Linux) without modification.
• Object-Oriented: Supports object-oriented programming (OOP)
principles like classes, inheritance, and polymorphism.
• Large Community & Support: Python has an active and vast
community, providing extensive documentation and resources.
• Integration Capabilities: Easily integrates with other
languages and technologies, such as C/C++, Java, and REST
APIs.
• Versatile: Suitable for a wide range of applications: web
development, data science, machine learning, automation, and
more.
Structure of python program
1. Shebang (Optional): 5. Main Program:
#!/usr/bin/env python3 The sequence of statements that run when the
Used to specify the interpreter (mainly in UNIX- program is executed.
like systems). if __name__ == "__main__":
2. Import Statements: greet()
Import required libraries or modules. 6. Statements and Expressions:
import math The actual operations that make up the program
(variable assignments, calculations, loops, etc.).
3. Docstrings (Optional):
x = 10
Documentation strings that describe the
program or functions. print(x * 2)
"""This is a simple Python program."""
4. Functions (Optional):
Reusable blocks of code.
def greet():
print("Hello, World!")
Structure of python program
(Cont…)
Python Components(Installed from
official site)
1. IDLE (Python GUI):
1. Description: An Integrated Development Environment (IDE)
provided with Python for editing and running Python
programs.
2. Features:
1. Python Shell for interactive scripting.
2. Text editor for creating and modifying Python source code.
3. Interactive debugger for error detection.
4. Built-in help system.
3. Cross-Platform: Available on Windows, macOS, and Linux.
Python Components (Cont…)
2. Module Docs:
• Description: Allows access to Python documentation, including
built-in modules, DLLs, libraries, and packages.
• Features:
• Provides comprehensive reference for all Python modules.
• Helps in learning and implementing various libraries.
3. Python (Command Line):
• Description: Python can be accessed directly from the command
line interface (CLI).
• Features:
• Provides quick execution of Python scripts.
• Lacks features like an editor or debugging tools compared to IDLE.
• Offers faster execution and simple interface for scripting.
Python Components (Cont…)

4. Python Manual:
• Description: Includes various official documents about
Python.
• Features:
• Installation and setup guides.
• Tutorials for getting started with Python.
• Detailed Python API documentation.
• Frequently Asked Questions (FAQs) and troubleshooting.
IDEs for Python
1. PyCharm: 3. Spyder:
• Description: A popular Python IDE developed by • Description: A Python IDE tailored for data
JetBrains, available in both free (Community) and science and scientific computing.
paid (Professional) versions. • Features:
• Features: • Integrated with powerful libraries like NumPy, SciPy,
• Intelligent code completion and error checking. and Matplotlib.
• Powerful debugging and testing tools. • Variable explorer and IPython console for interactive
• Integrated version control (Git). development.
• • Suitable for data analysis, scientific computing, and
Supports web frameworks (Django, Flask) and
scientific libraries. machine learning.

2. VS Code (Visual Studio Code): 4. Jupyter Notebook:


• Description: A lightweight and customizable • Description: An open-source web application for
open-source IDE from Microsoft. creating and sharing documents that contain live
code, equations, visualizations, and narrative text.
• Features:
• Extensive extensions for Python and other languages.
• Features:
• • Supports interactive coding with immediate output.
Integrated terminal, debugging, and version control
(Git). • Ideal for data science, machine learning, and
• Supports Jupyter Notebooks and Python web academic research.
frameworks. • Can mix Python code with rich-text documentation
• Fast and easy to set up.: and visualizations.
Python Interpreter
• Python is a high level language. We know that computer
understand machine language or binary language which
is also known as low level language.
• The job to translate programming code written in high
level language to low level language is done with the
help of two type of softwares : compilers and
interpreters.
Working of Compiler
• Compiler is a special type of software it first check the
source code of the complete program for the syntax
errors, if no error found in the program code then the
source code of the program is converted to the machine
code and finally the executive file of the program is
created. The executive file can be executed by the CPU
and can produce desired result as per the program
requirements.
Working of Interpreter
• Interpreter check the code of program line by line if no error is found it is
converted into the machine code and simultaneously gets executed by the CPU.

• An interpreter is a computer program, which coverts each high-level program


statement into the machine code. This includes source code, pre-compiled code,
and scripts. Both compiler and interpreters do the same job which is converting
higher level programming language to machine code. However, a compiler will
convert the code into machine code (create an exe) before program run.
Interpreters convert code into machine code when the program is run.
Using Python as a Calculator
1. Basic Arithmetic Operations:
• Python can be used to perform standard arithmetic operations
like addition, subtraction, multiplication, and division.
a = 10
b=5
print(a + b) # Output: 15
print(a - b) # Output: 5
print(a * b) # Output: 50
print(a / b) # Output: 2.0
Using Python as a Calculator (Cont..)
2. Power and Modulus:
• You can calculate powers and find remainders with Python.
print(a ** b) # Power: 10 raised to the power 5 -> Output:
100000
print(a % b) # Modulus: Remainder when 10 is divided by
5 -> Output: 0
3. Order of Operations:
• Python respects standard mathematical order of operations
(PEMDAS - Parentheses, Exponents, Multiplication, Division,
Addition, Subtraction).
print(2 + 3 * 4) # Output: 14 (multiplication happens before addition)
print((2 + 3) * 4) # Output: 20 (parentheses take precedence)
Using Python as a Calculator (Cont..)
4. Floating-Point Numbers:
• Python supports decimal numbers (floats) for more precise
calculations.
x = 3.14
y = 2.5
print(x * y) # Output: 7.85
5. Using the math Module:
• Python's math module provides advanced mathematical functions
like square roots, trigonometric operations, and constants.
import math
print(math.sqrt(16)) # Output: 4.0
print(math.sin(math.pi / 2)) # Output: 1.0
Using Python as a Calculator (Cont..)

6. Using Python as a Scientific Calculator:


• Python can handle complex calculations with ease, including
operations with large numbers or advanced functions like
factorials and logarithms.
print(math.factorial(5)) # Output: 120
print(math.log(100, 10)) # Output: 2.0 (log base 10 of 100)
Python Shell
• The Python Shell (or Interactive Mode) is an
interactive interface that allows users to enter and
execute Python commands one at a time, providing
immediate feedback.
• It is also known as the REPL (Read-Eval-Print Loop),
where each line of code is read, evaluated, and printed
back as output.
• Launching the Python Shell:
• To start the Python Shell, simply type python or python3 in the
command line (depending on your environment).
python
• Basic Usage:
• You can directly enter Python code and get immediate results.

• Multi-Line Commands:
• You can write multi-line code in the shell by using indentation,
like loops or function definitions.
• Use for Debugging:
• The Python Shell is useful for testing small code snippets, experimenting with libraries, and
debugging programs in real-time.

• Exiting the Python Shell:


• To exit the shell, use the exit() command or press Ctrl + Z (Windows) or Ctrl + D
(Linux/macOS).
• Features:
• Immediate Execution: Immediate feedback for commands entered.
• Useful for Testing: Great for quick testing and exploration of Python syntax and functions.
• History Support: It keeps track of previously entered commands and allows you to
navigate through them with arrow keys.

You might also like