Python Programming unit 1
Python Programming unit 1
PROGRAMMING
Unit 1
Contents
• Origin
• Need of Python Programming
• Features
• Program Structure
• Identifiers
• Reserved Words
• IDLE-Python Interpreter
Origin
• created by Guido Van Rossum
• released on February 20, 1991
• maintained by Python Software Foundation, a non-profit membership organization
• The name python was inspired by Monty Python’s Flying Circus , which was a
very famous show on BBC back in the 1970s and Van Rossum happened to be a big
fan of that show.
• Python emphasizes code readability and its syntax allows programmers to write
codes in fewer lines compared to other languages
Need of Python Programming
• When compared to any other high-level programming languages such as C++ and
Java, it requires the programmer to develop lesser codes. Python is designed to be
simple and easy to read and write.
• Python can be utilized for a wide range of applications such as scripting,
developing, and testing. Because of its elegance and simplicity, Dropbox, Google,
Quora, Hewlett-Packard, and so many other top tech companies have already
implemented Python.
• With the growing trend of Data Science and Machine Learning, Python has equally
become one of the most important scripting languages in the 21st century, because
of its wide range of libraries and frameworks.
Features
• Object-Oriented: Python was created with an Object-oriented programming
approach which helps in writing clean and clear code. Object-oriented programming
can be achieved through Python Class.
• Use of Interpreter: Python codes are interpreted line by line at a time using the
Interpreter. This also helps in debugging.
• Free and Open-source: This is a free and open-source programming language so
everyone can use it.
• Simple: It is simple to use as it is just like an English sentence resulting in fast
coding and execution.
Features
• Can be Integrated: It can be integrated with other programming languages like C,
C+, Java, and many more. This will also teach you most of the programming
concepts.
• Cross-platform: Python is a cross-platform programming language which means it
allows you to use it on any platform like Windows, Linux, Mac, Unix, etc.
• Large library: Python’s ecosystem is large and growing, with a wide range of open-
source packages and libraries. There are over 137,000 Python libraries.
• Elegant Syntax: Python has a simple syntax that improves readability and lowers
code maintenance costs which makes code elegant and straightforward.
Program Structure
• Python is a high-level, interpreted programming language that is easy to learn and
use. It has a simple and easy-to-understand syntax that emphasizes readability and
reduces the cost of program maintenance. The basic structure of a Python program
consists of the following components:
• Comments: Comments are used to explain the purpose of the code or to make notes for
other programmers. They start with a ‘#’ symbol and are ignored by the interpreter.
• Import Statements: Import statements are used to import modules or libraries into the
program. These modules contain predefined functions that can be used to accomplish
tasks.
• Variables: Variables are used to store data in memory for later use. In Python, variables do
not need to be declared with a specific type.
• Data Types: Python supports several built-in data types including integers, floats, strings,
Booleans, and lists.
Program Structure
• Operators: Operators are used to perform operations on variables and data. Python
supports arithmetic, comparison, and logical operators.
• Control Structures: Control structures are used to control the flow of a program. Python
supports if-else statements, for loops, and while loops.
• Functions: Functions are used to group a set of related statements together and give them a
name. They can be reused throughout a program.
• Classes: Classes are used to define objects that have specific attributes and methods. They
are used to create more complex data structures and encapsulate code.
• Exceptions: Exceptions are used to handle errors that may occur during the execution of a
program.