SlideShare a Scribd company logo
03/06/2025
DEPARTMENT OF COMPUTER SCIENCE
Chapter 2
Introduction to Python
03/06/2025
History of Python
1
 Python was developed by Guido van Rossum in the late eighties and early nineties at
the National Research Institute for Mathematics and Computer Science in the
Netherlands.
 Python is derived from many other languages, including ABC, Modula-3, C, C++,
Algol-68, SmallTalk, and Unix shell and other scripting languages.
 Smalltalk is considered as the first truly object-oriented programming language.
 Python is copyrighted. Like Perl, Python source code is now available under the
free and open source General Public License (GPL).
 Python is now maintained by a core development team at the institute, although
Guido van Rossum still holds a vital role in directing its progress.
 Python is a high-level, general-purpose, and very popular programming
language.
 Python is currently the most widely used multi-purpose, high-level
programming language, which allows programming in Object-Oriented and
Procedural paradigms.
Introduction to python
2 03/06/2025
 This Python tutorial has been written for the beginners to help them
understand the basic to advanced concepts of Python Programming
Language.
 What is Python?
 is a very popular general-purpose interpreted, interactive, object-
oriented, and high-level programming language.
 Python is dynamically-typed and garbage-collected programming
language.
 It was created by Guido van Rossum during 1985- 1990. Like Perl,
Python source code is also available under the free and open source
General Public License (GPL).
 It uses English keywords frequently where as other languages use
punctuation, and it has fewer syntactical constructions than other
languages.
 Python supports multiple programming paradigms, including
Procedural, Object Oriented and Functional programming
language.
 Python design philosophy emphasizes code readability with the use of
significant indentation
 Python Jobs
 python is very high in demand and all the major companies are looking
for great Python Programmers to develop websites, software
components, and applications or to work with Data Science, AI,
and ML technologies. t's impossible to list all of the companies using
Python, to name a few big companies are:
 Example:- Google, NASA, Facebook, IBM,Amazon, Uber
2 03/06/2025
Cont…
03/06/2025
key advantages of learning Python:
5
 Python is Interpreted − Python is processed at runtime by the
interpreter. You do not need to compile your program before executing
it.This is similar to PERL and PHP.
 Python is Interactive −You can actually sit at a Python prompt and
interact with the interpreter directly to write your programs.
 Python is Object-Oriented − Python supports Object-Oriented
style or technique of programming that encapsulates code
within objects.
 Python is a Beginner's Language − Python is a great language for
the beginner-level programmers and supports the development of a wide
range of applications from simple text processing to WWW
browsers to games.
03/06/2025
Python Online Compiler/Interpreter
6
 Python Online Compiler/Interpreter which helps you to Edit and Execute the
code directly from your browser.
 Below code box allows you to change the value of the code.Try to change the
value inside print() and run it again to verify the result.
#This is my first Python program.
#This will print 'Hello,World!' as the output
print ("Hello,World!");
 Here are just a few of the career options where Python is a key skill:
 Game developer,Web designer, Python developer, Full-stack
developer, Machine learning engineer, Data scientist, Data analyst
 Data engineer
 DevOps engineer
 Software engineer
03/06/2025
Following are important characteristics of Python
Programming
7
 It supports functional and structured programming methods
as well as OOP.
 It can be used as a scripting language or can be compiled to
byte-code for building large applications.
 It provides very high-level dynamic data types and supports
dynamic type checking.
 Python will automatically clear old values out of memory in a
process known as garbage collection.
 It can be easily integrated with C, C++, COM, ActiveX, CORBA,
and Java.
03/06/2025
Why to Learn Python?
 It is consistently rated as one of the world's most popular programming
languages.
 There are many other good reasons which makes Python as the top
choice of any programmer:
 Python is Open Source which means its available free of cost.
 Python is simple and so easy to learn
 Python is versatile and can be used to create many different things.
 Python has powerful development libraries include AI, ML etc.
 Python is much in demand and ensures high salary
3
03/06/2025
Applications/ Features of Python
9
 Easy-to-learn − Python has few keywords, simple structure, and a
clearly defined syntax.
 Easy-to-read − Python code is more clearly defined and visible to the
eyes.
 Easy-to-maintain − source code is fairly easy-to-maintain.
 A broad standard library − Python's bulk of the library is very
portable and cross-platform compatible on UNIX,Windows, and
Macintosh.
 Interactive Mode − support for an interactive mode which allows
interactive testing and debugging of snippets of code.
 Portable − run on a wide variety of HW platforms and has the same
interface on all platforms.
03/06/2025
10
 Extendable −You can add low-level modules to the Python
interpreter.These modules enable programmers to add to or
customize their tools to be more efficient.
 Databases − Python provides interfaces to all major commercial
databases.
 GUI Programming − Python supports GUI applications that can be
created and ported to many system calls, libraries and windows
systems, such asWindows MFC, Macintosh, and the XWindow
system of Unix.
 Scalable − Python provides a better structure and support for
large programs than shell scripting.
Cont…
03/06/2025
Python - Environment Setup
11
 Python is available on a wide variety of platforms including Linux and
Mac OS X.
 Python has also been ported to the Java and .NET virtual machines
 Installing Python
 Python distribution is available for a wide variety of platforms.You
need to download only the binary code applicable for your platform
and install Python.
 If the binary code for your platform is not available, you need a C
compiler to compile the source code manually. Compiling the source
code offers more flexibility in terms of choice of features that you require
in your installation.
03/06/2025
Windows Installation
12
 Here are the steps to install Python onWindows machine.
 Open aWeb browser and go to https://www.python.org/downloads/.
 Follow the link for theWindows installer python-XYZ.msi file where XYZ
is the version you need to install.
 To use this installer python-XYZ.msi, theWindows system must support
Microsoft Installer 2.0. Save the installer file to your local machine and then
run it to find out if your machine supports MSI.
 Run the downloaded file.This brings up the Python install wizard, which is
really easy to use. Just accept the default settings, wait until the install is
finished, and you are done.
03/06/2025
Setting path atWindows
13
 To add the Python directory to the path for a particular
session inWindows −
 At the command prompt − type path %path%;C:Python
and press Enter.
 Note − C:Python is the path of the Python directory
03/06/2025
Python EnvironmentVariables
14
03/06/2025
Integrated Development Environment
15
 You can run Python from a Graphical User Interface (GUI) environment as well, if
you have a GUI application on your system that supports Python.
 Unix − Integrated Development and Learning Environment (IDLE) is the very
first Unix IDE for Python.
 Windows − PythonWin is the firstWindows interface for Python and is an IDE with
a GUI.
 Macintosh −The Macintosh version of Python along with the IDLE IDE is available
from the main website, downloadable as either MacBinary or BinHex'd files.
 We have provided Python Online Compiler/Interpreter which helps you to Edit
and Execute the code directly from your browser.Try to click the icon run button
to run the following Python code to print conventional "Hello,World!".
 #This is my first Python program.
 #This will print 'Hello,World!' as the output
 print ("Hello,World!")
 The print() function prints a message on the screen.
03/06/2025
16
 Python has a free integrated development environment known as
IDLE. IDLE stands for Integrated Development and Learning
Environment.To write Python codes, the interactive interpreter
or the text editor of the IDLE can be used.
 The interactive interpreter is used to write one line of Python code
at a time and is less convenient to write and execute a large
number of codes. Using the text editor, however, any
number of codes can be written and get executed with a single
command.
Cont..
03/06/2025
17
 Programs normally accept input and process the input to produce an
output.The print() function is used to produce output on the IDLE
shell.As shown in multiple examples in the preceding sections, the
print() function has the following syntax:
print([value])
 A function is a piece of code that performs some task and is called by
its name. It can be passed data as input to operate on, and can optionally
return data as output. print(), input() and type() are examples of
functions.
Cont..
03/06/2025
18
Cont..
03/06/2025
Python - Basic Syntax
19
 The Python syntax defines a set of rules that are used to create Python
statements while writing a Python Program.
 The Python Programming Language Syntax has many similarities to Perl,
C, and Java Programming Languages. However, there are some definite
differences between the languages.
 Python - Interactive Mode Programming
 We can invoke a Python interpreter from command line by typing
python at the command prompt as following −
 In Python, >>> is the prompt that indicates the interactive interpreter
is ready to accept commands.
 Let's type the following text at the Python prompt and press
the Enter −
 >>> print ("Hello,World!")
03/06/2025
Cont..
20
 If you are running older version of Python, like Python 2.4.x, then you
would need to use print statement without parenthesis as in print
"Hello,World!". However in Python version 3.x, this produces the following
result − Hello,World!
 Python - Script Mode Programming
 We can invoke the Python interpreter with a script parameter
which begins the execution of the script and continues until the
script is finished.When the script is finished, the interpreter is no
longer active.
 Let us write a simple Python program in a script which is simple text
file. Python files have extension .py. Type the following source code in a
test.py file −
03/06/2025
Python Identifiers
21
 A Python identifier is a name used to identify a Variable, Function,
Class, Module or other Object.
 In Python, modules are simply files that contain Python code.A
module can define functions, classes, and variables, and it can also include
runnable code.
 An identifier starts with a letter A to Z or a to z or an underscore (_)
followed by zero or more letters, underscores and digits (0 to 9).
 Python does not allow punctuation characters such as @, $, and %
within identifiers.
 Python is a case sensitive programming language.Thus,
Manpower and manpower are two different identifiers in Python.
03/06/2025
Here are naming conventions for Python identifiers −
22
 Python Class names start with an uppercase letter.
 All other identifiers start with a lowercase letter.
 Starting an identifier with a single leading underscore indicates that
the identifier is private identifier.
 In Python, a single leading underscore (_) before an identifier
(such as a variable or method name) is a convention that indicates that
the identifier is intended for internal use.
 Starting an identifier with two leading underscores indicates a
strongly private identifier.
 In Python, a strongly private identifier is indicated by using a
double leading underscore (__).
 If the identifier also ends with two trailing underscores, the
identifier is a language-defined special name.
03/06/2025
Cont…
23
#Valid Identifiers
 my_variable = 10
 MyVariable = 20
 _variable = 30
 variable1 = 40
# Using the identifiers in the program
 print(my_variable) # Output: 10
 print(MyVariable) # Output: 20
 print(_variable) # Output: 30
 print(variable1) # Output: 40
# Invalid Identifiers
 1st_variable = 50 # Invalid: cannot start with a digit
 my-variable = 60 # Invalid: hyphen is not allowed
 class = 70 # Invalid: 'class' is a reserved keyword
 total sum = 80 # Invalid: space is not allowed
# Uncommenting the invalid identifiers will raise a SyntaxError
03/06/2025
Python ReservedWords
24
 The following list shows the Python keywords.These are
reserved words and you cannot use them as constant or
variable or any other identifier names.All the Python keywords
contain lowercase letters only.
03/06/2025
Python Lines and Indentation
25
 Python programming provides no braces to indicate blocks of code
for class and function definitions or flow control. Blocks of code
are denoted by line indentation, which is rigidly enforced.
 The number of spaces in the indentation is variable, but all
statements within the block must be indented the same amount.
For example −
 However, the following block generates an error −
03/06/2025
Cont..
26
 Thus, in Python all the continuous lines indented with same
number of spaces would form a block.The following example has
various statement blocks −
 Do not try to understand the logic at this point of time. Just
make sure you understood various blocks even if they are without
braces.
 Python Multi-Line Statements
 Statements in Python typically end with a new line. Python does,
however, allow the use of the line continuation character () to
denote that the line should continue. For example −
 In Python, the line continuation character is the backslash . It is used
to continue a logical line of code across multiple physical lines.
03/06/2025
Cont..
27
 Statements contained within the [], {}, or () brackets do not need
to use the line continuation character. For example following
statement works well in Python −
days = ['Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday’]
 Quotations in Python
 Python accepts single ('), double (") and triple (''' or """) quotes
to denote string literals, as long as the same type of quote starts
and ends the string. The triple quotes are used to span the string across
multiple lines. For example, all the following are legal −
03/06/2025
Comments in Python
28
 A comment is a programmer-readable explanation or
annotation in the Python source code.
 They are added with the purpose of making the source code easier
for humans to understand, and are ignored by Python interpreter
 Just like most modern languages, Python supports single-line (or end-
of-line) and multi-line (block) comments.
 Python comments are very much similar to the comments available in
PHP, BASH and Perl Programming languages.
 A hash sign (#) that is not inside a string literal begins a comment.
All characters after the # and up to the end of the physical line are
part of the comment and the Python interpreter ignores them.
03/06/2025
Cont..
29
 comments enhance the readability of the code and help the
programmers to understand the code very carefully.
 There are three types of comments available in Python
 Single line Comments
 Multiline Comments
 Docstring Comments
 A hash sign (#) that is not inside a string literal begins a comment.
All characters after the # and up to the end of the physical line are part of
the comment and the Python interpreter ignores them.
 Following is an example of a single line comment in Python:
03/06/2025
Cont.
30
 Python does not provide a direct way to comment multiple line.
You can comment multiple lines as follows −


 Following triple-quoted string is also ignored by Python
interpreter and can be used as a multiline comments:
03/06/2025
31
 Docstring comments are used to provide documentation for
functions, classes, modules and Method.They are enclosed in
triple quotes (''' ''') and are accessible through the `__doc__`
attribute of the object. Docstrings are used to describe the purpose,
usage, and parameters of the object..
Docstring Comments
03/06/2025
32
 You can type a comment on the same line after a statement or expression −
name = "Madisetti" # This is again
comment
 You can comment multiple lines as follows −
 Following triple-quoted string is also ignored by Python interpreter and can
be used as a multiline comments:
 Using Blank Lines in Python Programs
 A line containing only whitespace, possibly with a comment, is known as a blank line
and Python totally ignores it.
 In an interactive interpreter session, you must enter an empty physical line to
terminate a multiline statement.
Cont…
03/06/2025
33
 The following line of the program displays the prompt, the statement
saying “Press the enter key to exit”, and waits for the user to take action −
 #!/usr/bin/python
 raw_input("nnPress the enter key to
exit.")
 Here, "nn" is used to create two new lines before displaying the actual
line. Once the user presses the key, the program ends
 Multiple Statements on a Single Line
 The semicolon ( ; ) allows multiple statements on the single line
given that neither statement starts a new code block. Here is a sample
snip using the semicolon −
Waiting for the User
03/06/2025
34
 A group of individual statements, which make a single code block
are called suites in Python. Compound or complex statements,
such as if, while, def, and class require a header line and a suite.
 Header lines begin the statement (with the keyword) and terminate
with a colon ( : ) and are followed by one or more lines which make up
the suite. For example −
Multiple Statement Groups as Suites
03/06/2025
Cont
35
 In Python, multiple statement groups are referred to as "suites" or
"blocks of code".A suite is a collection of one or more statements that are
executed as a unit.
 There are several constructs in Python that require a suite, such as:
 Compound Statements:
 if-else statements
 for loops
 while loops
 try-except blocks
 class and def definitions
 Functions and Methods:
 The body of a function or method is a suite.
 Modules and Classes:
 The top-level statements in a Python module or class are also
considered a suite.
03/06/2025
Python - Variables
36
 Python variables are the reserved memory locations used to store values with in a
Python Program.
 This means that when you create a variable you reserve some space in the memory.
 Based on the data type of a variable, Python interpreter allocates memory and decides
what can be stored in the reserved memory
 Therefore, by assigning different data types to Python variables, you can store integers,
decimals or characters in these variables.
 Creating PythonVariables
 Python variables do not need explicit declaration to reserve memory
space or you can say to create a variable.A Python variable is created
automatically when you assign a value to it.The equal sign (=) is used to
assign values to variables.
 The operand to the left of the = operator is the name of the variable and
the operand to the right of the = operator is the value stored in the
variable. For example −
03/06/2025
Printing Python Variables
37
 Once we create a Python variable and assign a value to it, we can print
it using print() function. Following is the extension of previous
example and shows how to print different variables in Python:
 Here, 100, 1000.0 and "Zara Ali" are the values assigned to counter,
miles, and name variables, respectively.When running the above
Python program, this produces the following result −
03/06/2025
38
 You can delete the reference to a number object by using the del
statement.The syntax of the del statement is −
del var1[,var2[,var3[....,varN]]]]
 You can delete a single object or multiple objects by using the del
statement. For example
 del var
 del var_a, var_b
 The Following examples shows how we can delete a variable and if we
try to use a deleted variable then Python interpreter will throw an
error:
Delete aVariable
03/06/2025
Multiple Assignment
39
 Python allows you to assign a single value to several variables
simultaneously which means you can create multiple variables at a
time. For example −
 Here, an integer object is created with the value 1, and all three
variables are assigned to the same memory location.You can also
assign multiple objects to multiple variables. For example −
03/06/2025
Python Variable Names
40
 Every Python variable should have a unique name like a, b, c.
 A variable name can be meaningful like color, age, name etc.
 There are certain rules which should be taken care while naming a
Python variable:
 A variable name must start with a letter or the underscore character
 A variable name cannot start with a number or any special character
like $, (, * % etc.
 A variable name can only contain alpha-numeric characters and
underscores (A-z, 0-9, and _ )
 Python variable names are case-sensitive which means Name and
NAME are two different variables in Python.
 Python reserved keywords cannot be used naming the variable.
03/06/2025
Cont.
41
 Example the following are valid Python variable names:
 Example the following are invalid Python variable names:
03/06/2025
Python Local Variable
42
 Python LocalVariables are defined inside a function.We can not
access variable outside the function.
 A Python functions is a piece of reusable code and you will learn
more about function in Python - Functions tutorial.
 Python GlobalVariable
 Any variable created outside a function can be accessed within any
function and so they have global scope. Following is an example of global
variables:
03/06/2025
Python - Data Types
43
 Python DataTypes are used to define the type of a variable. It defines what
type of data we are going to store in a variable.
 The data stored in memory can be of many types. For example, a
person's age is stored as a numeric value and his or her address is
stored as alphanumeric characters.
 Python has various built-in data types which we will discuss with in this
tutorial:
 Numeric - int, float, complex
 String - str
 Sequence - list, tuple, range
 Binary - bytes, bytearray, memoryview
 Mapping - dict
 Boolean - bool
 Set - set, frozenset
 None - NoneType
03/06/2025
Python Numeric Data Type
44
 Python numeric data types store numeric values. Number
objects are created when you assign a value to them. For example −
 Python supports four different numerical types −
 int (signed integers)
 long (long integers, they can also be represented in octal and
hexadecimal)
 float (floating point real values)
 complex (complex numbers)
03/06/2025
Examples Here are some examples of numbers −
45
 Python allows you to use a lowercase l with long, but it is
recommended that you use only an uppercase L to avoid confusion
with the number 1. Python displays long integers with an uppercase L.
 A complex number consists of an ordered pair of real floating-point
numbers denoted by x + yj, where x and y are the real numbers and j
is the imaginary unit.
03/06/2025
Following is an example to show the usage of Integer, Float and
Complex numbers:
46
 Python String DataType
 Python Strings are identified as a contiguous set of characters
represented in the quotation marks. Python allows for either pairs of
single or double quotes. Subsets of strings can be taken using the slice
operator ([ ] and [:] ) with indexes starting at 0 in the beginning of the
string and working their way from -1 at the end.
03/06/2025
Cont.
47
 The plus (+) sign is the string concatenation operator and the asterisk
(*) is the repetition operator in Python. For example −
 Python List DataType
 Python Lists are the most versatile compound data types.A Python list
contains items separated by commas and enclosed within square brackets
([]).
 To some extent, Python lists are similar to arrays in C. One difference between
them is that all the items belonging to a Python list can be of different data type
where as C array can store elements related to a particular data type.
03/06/2025
Cont.
48
 The values stored in a Python list can be accessed using the slice operator
([ ] and [:]) with indexes starting at 0 in the beginning of the list and working
their way to end -1.The plus (+) sign is the list concatenation operator,
and the asterisk (*) is the repetition operator. For example −
 PythonTuple DataType
 Python tuple is another sequence data type that is similar to a list.A Python
tuple consists of a number of values separated by commas. Unlike lists, however,
tuples are enclosed within parentheses.
03/06/2025
Cont.
49
 The main differences between lists and tuples are: Lists are enclosed
in brackets ( [ ] ) and their elements and size can be changed, while
tuples are enclosed in parentheses ( ( ) ) and cannot be updated.
Tuples can be thought of as read-only lists. For example −
 The main differences between lists and tuples are: Lists are enclosed
in brackets ( [ ] ) and their elements and size can be changed,
while tuples are enclosed in parentheses ( ( ) ) and cannot be
updated.Tuples can be thought of as read-only lists. For example −
03/06/2025
Cont..
50
 The following code is invalid with tuple, because we attempted to update a
tuple, which is not allowed. Similar case is possible with lists −
 Python Ranges:
 Python range() is an in-built function in Python which returns a sequence of numbers
starting from 0 and increments to 1 until it reaches a specified number.
 We use range() function with for and while loop to generate a sequence of numbers. Following
is the syntax of the function:
 Here is the description of the parameters used:
 start: Integer number to specify starting position, (Its optional, Default: 0)
 stop: Integer number to specify starting position (It's mandatory)
 step: Integer number to specify increment, (Its optional, Default: 1)

03/06/2025
Cont.
51
 The Following Examples is a program which uses for loop to print
number
 from 0 to 4 −
 Now let's modify above program to print the number starting from 1
instead of 0:
 Python Dictionary
 Python dictionaries are kind of hash table type. They work like associative
arrays or and consist of key-value pairs. A dictionary key can be almost any
Python type hashes found in Perl , but are usually numbers or strings.
Values, on the other hand, can be any arbitrary Python object.
 Dictionaries are enclosed by curly braces ({ }) and values can be assigned and
accessed using square braces ([]). For example −
03/06/2025
Cont.
52

 Python dictionaries have no concept of order among elements. It is
incorrect to say that the elements are "out of order"; they are simply
unordered.
03/06/2025
Python Boolean Data Types
53
 Python Boolean type is one of built-in data types which represents one of the two values either
True or False. Python bool() function allows you to evaluate the value of any expression and
returns either True or False based on the expression.
 Following is another program which evaluates the expressions and prints the return values:
03/06/2025
Python Data Type Conversion
54
 Sometimes, you may need to perform conversions between the
built-in data types.To convert data between different Python
data types, you simply use the type name as a function.
 Conversion to int
 Following is an example to convert number, float and string into
integer data type:

 Conversion to float: Following is an example to convert number,
float and string into float data type:
03/06/2025
Conversion to string
55
 example to convert number, float and string into string data type:
 DataType Conversion Functions: there are several built-in functions to perform
conversion from one data type to another.These functions return a new object representing
the converted value.
03/06/2025
Cont.
56
03/06/2025
Python - Operators
57
 Python operators are the constructs which can manipulate the value of
operands.These are symbols used for the purpose of logical, arithmetic
and various other operations.
 Consider the expression 4 + 5 = 9. Here, 4 and 5 are called operands and + is
called operator. In this tutorial, we will study different types of Python
operators.
 Types of Python Operators
 Python language supports the following types of operators.
• Arithmetic Operators
• Comparison (Relational) Operators
• Assignment Operators
• Logical Operators
• Bitwise Operators
• Membership Operators
• Identity Operators
03/06/2025
Python Arithmetic Operators
58
 are used to perform mathematical operations on numerical values.
These operations are Addition, Subtraction, Multiplication,
Division, Modulus, Exponents and Floor Division.

03/06/2025
Python Comparison Operators
59
 compare the values on either sides of them and decide the relation
among them.They are also called relational operators.These operators
are equal, not equal, greater than, less than, greater than or equal to
and less than or equal to.

03/06/2025
Python Assignment Operators
60
 are used to assign values to variables.These operators include simple
assignment operator, addition assign, subtraction assign,
multiplication assign, division and assign operators etc.
03/06/2025
Cont.
61
03/06/2025
Python Bitwise Operators
62
 It works on bits and performs bit by bit operation.Assume if a =
60; and b = 13; Now in the binary format their values will be 0011
1100 and 0000 1101 respectively. Following table lists out the bitwise
operators supported by Python language with an example each in
those, we use the above two variables (a and b) as operands −
03/06/2025
Cont.
63
03/06/2025
Python Logical Operators
64
 There are following logical operators supported by Python
language.Assume variable a holds 10 and variable b holds 20 then

 Python Membership Operators: Python’s membership operators
test for membership in a sequence, such as strings, lists, or tuples.
There are two membership operators as explained below −
03/06/2025
Python Identity Operators
65
 Identity operators compare the memory locations of two
objects.There are two Identity operators explained below −
 Python Operators Precedence: the following table lists all
operators from highest precedence to lowest.
03/06/2025
Cont.
66
03/06/2025
67
THANKYOU!

More Related Content

What's hot (20)

Game Development With Python and Pygame
Game Development With Python and PygameGame Development With Python and Pygame
Game Development With Python and Pygame
Chariza Pladin
 
Self-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to MicroservicesSelf-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to Microservices
Eberhard Wolff
 
Unreal Engine (For Creating Games) Presentation
Unreal Engine (For Creating Games) PresentationUnreal Engine (For Creating Games) Presentation
Unreal Engine (For Creating Games) Presentation
Nitin Sharma
 
PYTHON FEATURES.pptx
PYTHON FEATURES.pptxPYTHON FEATURES.pptx
PYTHON FEATURES.pptx
MaheShiva
 
Python tutorial for beginners - Tib academy
Python tutorial for beginners - Tib academyPython tutorial for beginners - Tib academy
Python tutorial for beginners - Tib academy
TIB Academy
 
Introduction to ios
Introduction to iosIntroduction to ios
Introduction to ios
Swapnali Pawar
 
Creww growth202010
Creww growth202010Creww growth202010
Creww growth202010
Kenta Kato
 
Python games
Python gamesPython games
Python games
molw
 
How to think like a computer scientist - Learn with python
How to think like a computer scientist - Learn with pythonHow to think like a computer scientist - Learn with python
How to think like a computer scientist - Learn with python
Rajendra Kumar Uppal
 
Android application-component
Android application-componentAndroid application-component
Android application-component
Ly Haza
 
Introduction To Open Source Licenses
Introduction To Open Source LicensesIntroduction To Open Source Licenses
Introduction To Open Source Licenses
Harley Pascua
 
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
nationalmobileapps
 
Python Summer Internship
Python Summer InternshipPython Summer Internship
Python Summer Internship
Atul Kumar
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Android
guest213e237
 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptx
hemantmohite6
 
Introduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptxIntroduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptx
GevitaChinnaiah
 
Python
PythonPython
Python
Learnbay Datascience
 
Designing applications with web access capabilities
Designing applications with web access capabilitiesDesigning applications with web access capabilities
Designing applications with web access capabilities
K Senthil Kumar
 
Python ppt
Python pptPython ppt
Python ppt
Mohita Pandey
 
Mobile App Development
Mobile App DevelopmentMobile App Development
Mobile App Development
Chris Morrell
 
Game Development With Python and Pygame
Game Development With Python and PygameGame Development With Python and Pygame
Game Development With Python and Pygame
Chariza Pladin
 
Self-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to MicroservicesSelf-contained Systems: A Different Approach to Microservices
Self-contained Systems: A Different Approach to Microservices
Eberhard Wolff
 
Unreal Engine (For Creating Games) Presentation
Unreal Engine (For Creating Games) PresentationUnreal Engine (For Creating Games) Presentation
Unreal Engine (For Creating Games) Presentation
Nitin Sharma
 
PYTHON FEATURES.pptx
PYTHON FEATURES.pptxPYTHON FEATURES.pptx
PYTHON FEATURES.pptx
MaheShiva
 
Python tutorial for beginners - Tib academy
Python tutorial for beginners - Tib academyPython tutorial for beginners - Tib academy
Python tutorial for beginners - Tib academy
TIB Academy
 
Creww growth202010
Creww growth202010Creww growth202010
Creww growth202010
Kenta Kato
 
Python games
Python gamesPython games
Python games
molw
 
How to think like a computer scientist - Learn with python
How to think like a computer scientist - Learn with pythonHow to think like a computer scientist - Learn with python
How to think like a computer scientist - Learn with python
Rajendra Kumar Uppal
 
Android application-component
Android application-componentAndroid application-component
Android application-component
Ly Haza
 
Introduction To Open Source Licenses
Introduction To Open Source LicensesIntroduction To Open Source Licenses
Introduction To Open Source Licenses
Harley Pascua
 
Python Summer Internship
Python Summer InternshipPython Summer Internship
Python Summer Internship
Atul Kumar
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Android
guest213e237
 
Introduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptxIntroduction to Python and Basic Syntax.pptx
Introduction to Python and Basic Syntax.pptx
GevitaChinnaiah
 
Designing applications with web access capabilities
Designing applications with web access capabilitiesDesigning applications with web access capabilities
Designing applications with web access capabilities
K Senthil Kumar
 
Mobile App Development
Mobile App DevelopmentMobile App Development
Mobile App Development
Chris Morrell
 

Similar to Chapter 2: Basics of programming pyton programming (20)

Summer Training Project.pdf
Summer Training Project.pdfSummer Training Project.pdf
Summer Training Project.pdf
Lovely professinal university
 
Cmpe202 01 Research
Cmpe202 01 ResearchCmpe202 01 Research
Cmpe202 01 Research
vladimirkorshak
 
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEWPYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
EditorIJAERD
 
Migration of Applications to Python is the most prudent Decision
Migration of Applications to Python is the most prudent DecisionMigration of Applications to Python is the most prudent Decision
Migration of Applications to Python is the most prudent Decision
Mindfire LLC
 
Python_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdfPython_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdf
VisionAcademyProfSac
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdf
bhagyashri686896
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdf
muzegharjanahai
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdf
sannykhopade
 
Python_final_print_batch_II_vision_academy (1).pdf
Python_final_print_batch_II_vision_academy (1).pdfPython_final_print_batch_II_vision_academy (1).pdf
Python_final_print_batch_II_vision_academy (1).pdf
rupaliakhute
 
Python_vision_academy notes
Python_vision_academy notes Python_vision_academy notes
Python_vision_academy notes
rajaniraut
 
university notes Lecture - 1 (Python) E-Notes.pptx
university notes Lecture - 1 (Python) E-Notes.pptxuniversity notes Lecture - 1 (Python) E-Notes.pptx
university notes Lecture - 1 (Python) E-Notes.pptx
7ja1nyx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
Ramakrishna Reddy Bijjam
 
introduction to python in computer graphics.pptx
introduction to python in computer graphics.pptxintroduction to python in computer graphics.pptx
introduction to python in computer graphics.pptx
urvashipundir04
 
Research paper on python by Rj
Research paper on python by RjResearch paper on python by Rj
Research paper on python by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
IRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming LanguageIRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming Language
IRJET Journal
 
Python Programming Draft PPT.pptx
Python Programming Draft PPT.pptxPython Programming Draft PPT.pptx
Python Programming Draft PPT.pptx
LakshmiNarayanaReddy48
 
session5-Getting stated with Python.pdf
session5-Getting stated with Python.pdfsession5-Getting stated with Python.pdf
session5-Getting stated with Python.pdf
AyushDutta32
 
Fantasy cricket game using python(intershala project)
Fantasy cricket game using python(intershala project)Fantasy cricket game using python(intershala project)
Fantasy cricket game using python(intershala project)
Rr
 
python programminig and introduction.pptx
python programminig and introduction.pptxpython programminig and introduction.pptx
python programminig and introduction.pptx
urvashipundir04
 
Introduction to the Python
Introduction to the PythonIntroduction to the Python
Introduction to the Python
BMS Institute of Technology and Management
 
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEWPYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
EditorIJAERD
 
Migration of Applications to Python is the most prudent Decision
Migration of Applications to Python is the most prudent DecisionMigration of Applications to Python is the most prudent Decision
Migration of Applications to Python is the most prudent Decision
Mindfire LLC
 
Python_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdfPython_final_print_vison_academy_9822506209.pdf
Python_final_print_vison_academy_9822506209.pdf
VisionAcademyProfSac
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdf
bhagyashri686896
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdf
muzegharjanahai
 
Python_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdfPython_final_print_batch_II_vision_academy.pdf
Python_final_print_batch_II_vision_academy.pdf
sannykhopade
 
Python_final_print_batch_II_vision_academy (1).pdf
Python_final_print_batch_II_vision_academy (1).pdfPython_final_print_batch_II_vision_academy (1).pdf
Python_final_print_batch_II_vision_academy (1).pdf
rupaliakhute
 
Python_vision_academy notes
Python_vision_academy notes Python_vision_academy notes
Python_vision_academy notes
rajaniraut
 
university notes Lecture - 1 (Python) E-Notes.pptx
university notes Lecture - 1 (Python) E-Notes.pptxuniversity notes Lecture - 1 (Python) E-Notes.pptx
university notes Lecture - 1 (Python) E-Notes.pptx
7ja1nyx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
Ramakrishna Reddy Bijjam
 
introduction to python in computer graphics.pptx
introduction to python in computer graphics.pptxintroduction to python in computer graphics.pptx
introduction to python in computer graphics.pptx
urvashipundir04
 
IRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming LanguageIRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming Language
IRJET Journal
 
session5-Getting stated with Python.pdf
session5-Getting stated with Python.pdfsession5-Getting stated with Python.pdf
session5-Getting stated with Python.pdf
AyushDutta32
 
Fantasy cricket game using python(intershala project)
Fantasy cricket game using python(intershala project)Fantasy cricket game using python(intershala project)
Fantasy cricket game using python(intershala project)
Rr
 
python programminig and introduction.pptx
python programminig and introduction.pptxpython programminig and introduction.pptx
python programminig and introduction.pptx
urvashipundir04
 
Ad

Recently uploaded (20)

TRABAJO INGLÉSssssssssssssssssssss (2).pptx
TRABAJO INGLÉSssssssssssssssssssss (2).pptxTRABAJO INGLÉSssssssssssssssssssss (2).pptx
TRABAJO INGLÉSssssssssssssssssssss (2).pptx
alejandroreina25
 
Abzymes mimickers in catalytic reactions at nanoscales
Abzymes mimickers in catalytic reactions at nanoscalesAbzymes mimickers in catalytic reactions at nanoscales
Abzymes mimickers in catalytic reactions at nanoscales
OrchideaMariaLecian
 
Primary and Secondary immune modulation.pptx
Primary and Secondary immune modulation.pptxPrimary and Secondary immune modulation.pptx
Primary and Secondary immune modulation.pptx
devikasanalkumar35
 
Gene Expression & Regulation in Eukaryotes.pptx
Gene Expression & Regulation in Eukaryotes.pptxGene Expression & Regulation in Eukaryotes.pptx
Gene Expression & Regulation in Eukaryotes.pptx
Muhammad Hassan Asadi
 
Algebra A BASIC REVIEW INTERMEDICATE ALGEBRA
Algebra A BASIC REVIEW INTERMEDICATE ALGEBRAAlgebra A BASIC REVIEW INTERMEDICATE ALGEBRA
Algebra A BASIC REVIEW INTERMEDICATE ALGEBRA
ropamadoda
 
Kim Sandwich Biomes Project Science 10.pptx
Kim Sandwich Biomes Project Science 10.pptxKim Sandwich Biomes Project Science 10.pptx
Kim Sandwich Biomes Project Science 10.pptx
asantos691
 
esmo-academy-2024-pptx-template smyth final.pdf
esmo-academy-2024-pptx-template smyth final.pdfesmo-academy-2024-pptx-template smyth final.pdf
esmo-academy-2024-pptx-template smyth final.pdf
GuillermoGutirrez33
 
Comparative anatomy of brain of different types of vertebrates
Comparative anatomy of brain of different types of vertebratesComparative anatomy of brain of different types of vertebrates
Comparative anatomy of brain of different types of vertebrates
arpanmaji480
 
Telehealth For Maternal and Child Health: Expanding Access (www.kiu.ac.ug)
Telehealth For Maternal and Child Health: Expanding  Access (www.kiu.ac.ug)Telehealth For Maternal and Child Health: Expanding  Access (www.kiu.ac.ug)
Telehealth For Maternal and Child Health: Expanding Access (www.kiu.ac.ug)
publication11
 
Grammar-Based 
Interactive Visualization of Genomics Data
Grammar-Based 
Interactive Visualization of Genomics DataGrammar-Based 
Interactive Visualization of Genomics Data
Grammar-Based 
Interactive Visualization of Genomics Data
sehilyi
 
National development you must learn it.pptx
National development you must learn it.pptxNational development you must learn it.pptx
National development you must learn it.pptx
mukherjeechetan56
 
Aquatic ecosystem and its biomes involved.pdf
Aquatic ecosystem and its biomes involved.pdfAquatic ecosystem and its biomes involved.pdf
Aquatic ecosystem and its biomes involved.pdf
camillemaguid53
 
Microbiome Engineering: Shaping a Sustainable Future.pptx
Microbiome Engineering: Shaping a Sustainable Future.pptxMicrobiome Engineering: Shaping a Sustainable Future.pptx
Microbiome Engineering: Shaping a Sustainable Future.pptx
akshjm123
 
Dr. James Farley Identifies the Key Root Causes You Must Address to Heal Natu...
Dr. James Farley Identifies the Key Root Causes You Must Address to Heal Natu...Dr. James Farley Identifies the Key Root Causes You Must Address to Heal Natu...
Dr. James Farley Identifies the Key Root Causes You Must Address to Heal Natu...
DrJamesFarley
 
CULTIVATION - HARVESTING - PROCESSING - STORAGE -.pdf
CULTIVATION - HARVESTING - PROCESSING - STORAGE -.pdfCULTIVATION - HARVESTING - PROCESSING - STORAGE -.pdf
CULTIVATION - HARVESTING - PROCESSING - STORAGE -.pdf
Nistarini College, Purulia (W.B) India
 
HOW TO FACE THREATS FROM THE FORCES OF NATURE EXISTING ON PLANET EARTH.pdf
HOW TO FACE THREATS FROM THE FORCES OF NATURE EXISTING ON PLANET EARTH.pdfHOW TO FACE THREATS FROM THE FORCES OF NATURE EXISTING ON PLANET EARTH.pdf
HOW TO FACE THREATS FROM THE FORCES OF NATURE EXISTING ON PLANET EARTH.pdf
Faga1939
 
the presentation on downstream processing (DSP).pptx
the presentation on downstream processing (DSP).pptxthe presentation on downstream processing (DSP).pptx
the presentation on downstream processing (DSP).pptx
aanchalm373
 
Immunity and its Types.hububhubibkinunubunni
Immunity and its Types.hububhubibkinunubunniImmunity and its Types.hububhubibkinunubunni
Immunity and its Types.hububhubibkinunubunni
Manveer19
 
Multi-View Design Patterns & 
Responsive Visualization for
Genomics Data
Multi-View Design Patterns & 
Responsive Visualization for
Genomics DataMulti-View Design Patterns & 
Responsive Visualization for
Genomics Data
Multi-View Design Patterns & 
Responsive Visualization for
Genomics Data
sehilyi
 
Comparative Layouts Revisited: Design Space, Guidelines, and Future Directions
Comparative Layouts Revisited: Design Space, Guidelines, and Future DirectionsComparative Layouts Revisited: Design Space, Guidelines, and Future Directions
Comparative Layouts Revisited: Design Space, Guidelines, and Future Directions
sehilyi
 
TRABAJO INGLÉSssssssssssssssssssss (2).pptx
TRABAJO INGLÉSssssssssssssssssssss (2).pptxTRABAJO INGLÉSssssssssssssssssssss (2).pptx
TRABAJO INGLÉSssssssssssssssssssss (2).pptx
alejandroreina25
 
Abzymes mimickers in catalytic reactions at nanoscales
Abzymes mimickers in catalytic reactions at nanoscalesAbzymes mimickers in catalytic reactions at nanoscales
Abzymes mimickers in catalytic reactions at nanoscales
OrchideaMariaLecian
 
Primary and Secondary immune modulation.pptx
Primary and Secondary immune modulation.pptxPrimary and Secondary immune modulation.pptx
Primary and Secondary immune modulation.pptx
devikasanalkumar35
 
Gene Expression & Regulation in Eukaryotes.pptx
Gene Expression & Regulation in Eukaryotes.pptxGene Expression & Regulation in Eukaryotes.pptx
Gene Expression & Regulation in Eukaryotes.pptx
Muhammad Hassan Asadi
 
Algebra A BASIC REVIEW INTERMEDICATE ALGEBRA
Algebra A BASIC REVIEW INTERMEDICATE ALGEBRAAlgebra A BASIC REVIEW INTERMEDICATE ALGEBRA
Algebra A BASIC REVIEW INTERMEDICATE ALGEBRA
ropamadoda
 
Kim Sandwich Biomes Project Science 10.pptx
Kim Sandwich Biomes Project Science 10.pptxKim Sandwich Biomes Project Science 10.pptx
Kim Sandwich Biomes Project Science 10.pptx
asantos691
 
esmo-academy-2024-pptx-template smyth final.pdf
esmo-academy-2024-pptx-template smyth final.pdfesmo-academy-2024-pptx-template smyth final.pdf
esmo-academy-2024-pptx-template smyth final.pdf
GuillermoGutirrez33
 
Comparative anatomy of brain of different types of vertebrates
Comparative anatomy of brain of different types of vertebratesComparative anatomy of brain of different types of vertebrates
Comparative anatomy of brain of different types of vertebrates
arpanmaji480
 
Telehealth For Maternal and Child Health: Expanding Access (www.kiu.ac.ug)
Telehealth For Maternal and Child Health: Expanding  Access (www.kiu.ac.ug)Telehealth For Maternal and Child Health: Expanding  Access (www.kiu.ac.ug)
Telehealth For Maternal and Child Health: Expanding Access (www.kiu.ac.ug)
publication11
 
Grammar-Based 
Interactive Visualization of Genomics Data
Grammar-Based 
Interactive Visualization of Genomics DataGrammar-Based 
Interactive Visualization of Genomics Data
Grammar-Based 
Interactive Visualization of Genomics Data
sehilyi
 
National development you must learn it.pptx
National development you must learn it.pptxNational development you must learn it.pptx
National development you must learn it.pptx
mukherjeechetan56
 
Aquatic ecosystem and its biomes involved.pdf
Aquatic ecosystem and its biomes involved.pdfAquatic ecosystem and its biomes involved.pdf
Aquatic ecosystem and its biomes involved.pdf
camillemaguid53
 
Microbiome Engineering: Shaping a Sustainable Future.pptx
Microbiome Engineering: Shaping a Sustainable Future.pptxMicrobiome Engineering: Shaping a Sustainable Future.pptx
Microbiome Engineering: Shaping a Sustainable Future.pptx
akshjm123
 
Dr. James Farley Identifies the Key Root Causes You Must Address to Heal Natu...
Dr. James Farley Identifies the Key Root Causes You Must Address to Heal Natu...Dr. James Farley Identifies the Key Root Causes You Must Address to Heal Natu...
Dr. James Farley Identifies the Key Root Causes You Must Address to Heal Natu...
DrJamesFarley
 
HOW TO FACE THREATS FROM THE FORCES OF NATURE EXISTING ON PLANET EARTH.pdf
HOW TO FACE THREATS FROM THE FORCES OF NATURE EXISTING ON PLANET EARTH.pdfHOW TO FACE THREATS FROM THE FORCES OF NATURE EXISTING ON PLANET EARTH.pdf
HOW TO FACE THREATS FROM THE FORCES OF NATURE EXISTING ON PLANET EARTH.pdf
Faga1939
 
the presentation on downstream processing (DSP).pptx
the presentation on downstream processing (DSP).pptxthe presentation on downstream processing (DSP).pptx
the presentation on downstream processing (DSP).pptx
aanchalm373
 
Immunity and its Types.hububhubibkinunubunni
Immunity and its Types.hububhubibkinunubunniImmunity and its Types.hububhubibkinunubunni
Immunity and its Types.hububhubibkinunubunni
Manveer19
 
Multi-View Design Patterns & 
Responsive Visualization for
Genomics Data
Multi-View Design Patterns & 
Responsive Visualization for
Genomics DataMulti-View Design Patterns & 
Responsive Visualization for
Genomics Data
Multi-View Design Patterns & 
Responsive Visualization for
Genomics Data
sehilyi
 
Comparative Layouts Revisited: Design Space, Guidelines, and Future Directions
Comparative Layouts Revisited: Design Space, Guidelines, and Future DirectionsComparative Layouts Revisited: Design Space, Guidelines, and Future Directions
Comparative Layouts Revisited: Design Space, Guidelines, and Future Directions
sehilyi
 
Ad

Chapter 2: Basics of programming pyton programming

  • 1. 03/06/2025 DEPARTMENT OF COMPUTER SCIENCE Chapter 2 Introduction to Python
  • 2. 03/06/2025 History of Python 1  Python was developed by Guido van Rossum in the late eighties and early nineties at the National Research Institute for Mathematics and Computer Science in the Netherlands.  Python is derived from many other languages, including ABC, Modula-3, C, C++, Algol-68, SmallTalk, and Unix shell and other scripting languages.  Smalltalk is considered as the first truly object-oriented programming language.  Python is copyrighted. Like Perl, Python source code is now available under the free and open source General Public License (GPL).  Python is now maintained by a core development team at the institute, although Guido van Rossum still holds a vital role in directing its progress.  Python is a high-level, general-purpose, and very popular programming language.  Python is currently the most widely used multi-purpose, high-level programming language, which allows programming in Object-Oriented and Procedural paradigms.
  • 3. Introduction to python 2 03/06/2025  This Python tutorial has been written for the beginners to help them understand the basic to advanced concepts of Python Programming Language.  What is Python?  is a very popular general-purpose interpreted, interactive, object- oriented, and high-level programming language.  Python is dynamically-typed and garbage-collected programming language.  It was created by Guido van Rossum during 1985- 1990. Like Perl, Python source code is also available under the free and open source General Public License (GPL).  It uses English keywords frequently where as other languages use punctuation, and it has fewer syntactical constructions than other languages.
  • 4.  Python supports multiple programming paradigms, including Procedural, Object Oriented and Functional programming language.  Python design philosophy emphasizes code readability with the use of significant indentation  Python Jobs  python is very high in demand and all the major companies are looking for great Python Programmers to develop websites, software components, and applications or to work with Data Science, AI, and ML technologies. t's impossible to list all of the companies using Python, to name a few big companies are:  Example:- Google, NASA, Facebook, IBM,Amazon, Uber 2 03/06/2025 Cont…
  • 5. 03/06/2025 key advantages of learning Python: 5  Python is Interpreted − Python is processed at runtime by the interpreter. You do not need to compile your program before executing it.This is similar to PERL and PHP.  Python is Interactive −You can actually sit at a Python prompt and interact with the interpreter directly to write your programs.  Python is Object-Oriented − Python supports Object-Oriented style or technique of programming that encapsulates code within objects.  Python is a Beginner's Language − Python is a great language for the beginner-level programmers and supports the development of a wide range of applications from simple text processing to WWW browsers to games.
  • 6. 03/06/2025 Python Online Compiler/Interpreter 6  Python Online Compiler/Interpreter which helps you to Edit and Execute the code directly from your browser.  Below code box allows you to change the value of the code.Try to change the value inside print() and run it again to verify the result. #This is my first Python program. #This will print 'Hello,World!' as the output print ("Hello,World!");  Here are just a few of the career options where Python is a key skill:  Game developer,Web designer, Python developer, Full-stack developer, Machine learning engineer, Data scientist, Data analyst  Data engineer  DevOps engineer  Software engineer
  • 7. 03/06/2025 Following are important characteristics of Python Programming 7  It supports functional and structured programming methods as well as OOP.  It can be used as a scripting language or can be compiled to byte-code for building large applications.  It provides very high-level dynamic data types and supports dynamic type checking.  Python will automatically clear old values out of memory in a process known as garbage collection.  It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
  • 8. 03/06/2025 Why to Learn Python?  It is consistently rated as one of the world's most popular programming languages.  There are many other good reasons which makes Python as the top choice of any programmer:  Python is Open Source which means its available free of cost.  Python is simple and so easy to learn  Python is versatile and can be used to create many different things.  Python has powerful development libraries include AI, ML etc.  Python is much in demand and ensures high salary 3
  • 9. 03/06/2025 Applications/ Features of Python 9  Easy-to-learn − Python has few keywords, simple structure, and a clearly defined syntax.  Easy-to-read − Python code is more clearly defined and visible to the eyes.  Easy-to-maintain − source code is fairly easy-to-maintain.  A broad standard library − Python's bulk of the library is very portable and cross-platform compatible on UNIX,Windows, and Macintosh.  Interactive Mode − support for an interactive mode which allows interactive testing and debugging of snippets of code.  Portable − run on a wide variety of HW platforms and has the same interface on all platforms.
  • 10. 03/06/2025 10  Extendable −You can add low-level modules to the Python interpreter.These modules enable programmers to add to or customize their tools to be more efficient.  Databases − Python provides interfaces to all major commercial databases.  GUI Programming − Python supports GUI applications that can be created and ported to many system calls, libraries and windows systems, such asWindows MFC, Macintosh, and the XWindow system of Unix.  Scalable − Python provides a better structure and support for large programs than shell scripting. Cont…
  • 11. 03/06/2025 Python - Environment Setup 11  Python is available on a wide variety of platforms including Linux and Mac OS X.  Python has also been ported to the Java and .NET virtual machines  Installing Python  Python distribution is available for a wide variety of platforms.You need to download only the binary code applicable for your platform and install Python.  If the binary code for your platform is not available, you need a C compiler to compile the source code manually. Compiling the source code offers more flexibility in terms of choice of features that you require in your installation.
  • 12. 03/06/2025 Windows Installation 12  Here are the steps to install Python onWindows machine.  Open aWeb browser and go to https://www.python.org/downloads/.  Follow the link for theWindows installer python-XYZ.msi file where XYZ is the version you need to install.  To use this installer python-XYZ.msi, theWindows system must support Microsoft Installer 2.0. Save the installer file to your local machine and then run it to find out if your machine supports MSI.  Run the downloaded file.This brings up the Python install wizard, which is really easy to use. Just accept the default settings, wait until the install is finished, and you are done.
  • 13. 03/06/2025 Setting path atWindows 13  To add the Python directory to the path for a particular session inWindows −  At the command prompt − type path %path%;C:Python and press Enter.  Note − C:Python is the path of the Python directory
  • 15. 03/06/2025 Integrated Development Environment 15  You can run Python from a Graphical User Interface (GUI) environment as well, if you have a GUI application on your system that supports Python.  Unix − Integrated Development and Learning Environment (IDLE) is the very first Unix IDE for Python.  Windows − PythonWin is the firstWindows interface for Python and is an IDE with a GUI.  Macintosh −The Macintosh version of Python along with the IDLE IDE is available from the main website, downloadable as either MacBinary or BinHex'd files.  We have provided Python Online Compiler/Interpreter which helps you to Edit and Execute the code directly from your browser.Try to click the icon run button to run the following Python code to print conventional "Hello,World!".  #This is my first Python program.  #This will print 'Hello,World!' as the output  print ("Hello,World!")  The print() function prints a message on the screen.
  • 16. 03/06/2025 16  Python has a free integrated development environment known as IDLE. IDLE stands for Integrated Development and Learning Environment.To write Python codes, the interactive interpreter or the text editor of the IDLE can be used.  The interactive interpreter is used to write one line of Python code at a time and is less convenient to write and execute a large number of codes. Using the text editor, however, any number of codes can be written and get executed with a single command. Cont..
  • 17. 03/06/2025 17  Programs normally accept input and process the input to produce an output.The print() function is used to produce output on the IDLE shell.As shown in multiple examples in the preceding sections, the print() function has the following syntax: print([value])  A function is a piece of code that performs some task and is called by its name. It can be passed data as input to operate on, and can optionally return data as output. print(), input() and type() are examples of functions. Cont..
  • 19. 03/06/2025 Python - Basic Syntax 19  The Python syntax defines a set of rules that are used to create Python statements while writing a Python Program.  The Python Programming Language Syntax has many similarities to Perl, C, and Java Programming Languages. However, there are some definite differences between the languages.  Python - Interactive Mode Programming  We can invoke a Python interpreter from command line by typing python at the command prompt as following −  In Python, >>> is the prompt that indicates the interactive interpreter is ready to accept commands.  Let's type the following text at the Python prompt and press the Enter −  >>> print ("Hello,World!")
  • 20. 03/06/2025 Cont.. 20  If you are running older version of Python, like Python 2.4.x, then you would need to use print statement without parenthesis as in print "Hello,World!". However in Python version 3.x, this produces the following result − Hello,World!  Python - Script Mode Programming  We can invoke the Python interpreter with a script parameter which begins the execution of the script and continues until the script is finished.When the script is finished, the interpreter is no longer active.  Let us write a simple Python program in a script which is simple text file. Python files have extension .py. Type the following source code in a test.py file −
  • 21. 03/06/2025 Python Identifiers 21  A Python identifier is a name used to identify a Variable, Function, Class, Module or other Object.  In Python, modules are simply files that contain Python code.A module can define functions, classes, and variables, and it can also include runnable code.  An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9).  Python does not allow punctuation characters such as @, $, and % within identifiers.  Python is a case sensitive programming language.Thus, Manpower and manpower are two different identifiers in Python.
  • 22. 03/06/2025 Here are naming conventions for Python identifiers − 22  Python Class names start with an uppercase letter.  All other identifiers start with a lowercase letter.  Starting an identifier with a single leading underscore indicates that the identifier is private identifier.  In Python, a single leading underscore (_) before an identifier (such as a variable or method name) is a convention that indicates that the identifier is intended for internal use.  Starting an identifier with two leading underscores indicates a strongly private identifier.  In Python, a strongly private identifier is indicated by using a double leading underscore (__).  If the identifier also ends with two trailing underscores, the identifier is a language-defined special name.
  • 23. 03/06/2025 Cont… 23 #Valid Identifiers  my_variable = 10  MyVariable = 20  _variable = 30  variable1 = 40 # Using the identifiers in the program  print(my_variable) # Output: 10  print(MyVariable) # Output: 20  print(_variable) # Output: 30  print(variable1) # Output: 40 # Invalid Identifiers  1st_variable = 50 # Invalid: cannot start with a digit  my-variable = 60 # Invalid: hyphen is not allowed  class = 70 # Invalid: 'class' is a reserved keyword  total sum = 80 # Invalid: space is not allowed # Uncommenting the invalid identifiers will raise a SyntaxError
  • 24. 03/06/2025 Python ReservedWords 24  The following list shows the Python keywords.These are reserved words and you cannot use them as constant or variable or any other identifier names.All the Python keywords contain lowercase letters only.
  • 25. 03/06/2025 Python Lines and Indentation 25  Python programming provides no braces to indicate blocks of code for class and function definitions or flow control. Blocks of code are denoted by line indentation, which is rigidly enforced.  The number of spaces in the indentation is variable, but all statements within the block must be indented the same amount. For example −  However, the following block generates an error −
  • 26. 03/06/2025 Cont.. 26  Thus, in Python all the continuous lines indented with same number of spaces would form a block.The following example has various statement blocks −  Do not try to understand the logic at this point of time. Just make sure you understood various blocks even if they are without braces.  Python Multi-Line Statements  Statements in Python typically end with a new line. Python does, however, allow the use of the line continuation character () to denote that the line should continue. For example −  In Python, the line continuation character is the backslash . It is used to continue a logical line of code across multiple physical lines.
  • 27. 03/06/2025 Cont.. 27  Statements contained within the [], {}, or () brackets do not need to use the line continuation character. For example following statement works well in Python − days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday’]  Quotations in Python  Python accepts single ('), double (") and triple (''' or """) quotes to denote string literals, as long as the same type of quote starts and ends the string. The triple quotes are used to span the string across multiple lines. For example, all the following are legal −
  • 28. 03/06/2025 Comments in Python 28  A comment is a programmer-readable explanation or annotation in the Python source code.  They are added with the purpose of making the source code easier for humans to understand, and are ignored by Python interpreter  Just like most modern languages, Python supports single-line (or end- of-line) and multi-line (block) comments.  Python comments are very much similar to the comments available in PHP, BASH and Perl Programming languages.  A hash sign (#) that is not inside a string literal begins a comment. All characters after the # and up to the end of the physical line are part of the comment and the Python interpreter ignores them.
  • 29. 03/06/2025 Cont.. 29  comments enhance the readability of the code and help the programmers to understand the code very carefully.  There are three types of comments available in Python  Single line Comments  Multiline Comments  Docstring Comments  A hash sign (#) that is not inside a string literal begins a comment. All characters after the # and up to the end of the physical line are part of the comment and the Python interpreter ignores them.  Following is an example of a single line comment in Python:
  • 30. 03/06/2025 Cont. 30  Python does not provide a direct way to comment multiple line. You can comment multiple lines as follows −    Following triple-quoted string is also ignored by Python interpreter and can be used as a multiline comments:
  • 31. 03/06/2025 31  Docstring comments are used to provide documentation for functions, classes, modules and Method.They are enclosed in triple quotes (''' ''') and are accessible through the `__doc__` attribute of the object. Docstrings are used to describe the purpose, usage, and parameters of the object.. Docstring Comments
  • 32. 03/06/2025 32  You can type a comment on the same line after a statement or expression − name = "Madisetti" # This is again comment  You can comment multiple lines as follows −  Following triple-quoted string is also ignored by Python interpreter and can be used as a multiline comments:  Using Blank Lines in Python Programs  A line containing only whitespace, possibly with a comment, is known as a blank line and Python totally ignores it.  In an interactive interpreter session, you must enter an empty physical line to terminate a multiline statement. Cont…
  • 33. 03/06/2025 33  The following line of the program displays the prompt, the statement saying “Press the enter key to exit”, and waits for the user to take action −  #!/usr/bin/python  raw_input("nnPress the enter key to exit.")  Here, "nn" is used to create two new lines before displaying the actual line. Once the user presses the key, the program ends  Multiple Statements on a Single Line  The semicolon ( ; ) allows multiple statements on the single line given that neither statement starts a new code block. Here is a sample snip using the semicolon − Waiting for the User
  • 34. 03/06/2025 34  A group of individual statements, which make a single code block are called suites in Python. Compound or complex statements, such as if, while, def, and class require a header line and a suite.  Header lines begin the statement (with the keyword) and terminate with a colon ( : ) and are followed by one or more lines which make up the suite. For example − Multiple Statement Groups as Suites
  • 35. 03/06/2025 Cont 35  In Python, multiple statement groups are referred to as "suites" or "blocks of code".A suite is a collection of one or more statements that are executed as a unit.  There are several constructs in Python that require a suite, such as:  Compound Statements:  if-else statements  for loops  while loops  try-except blocks  class and def definitions  Functions and Methods:  The body of a function or method is a suite.  Modules and Classes:  The top-level statements in a Python module or class are also considered a suite.
  • 36. 03/06/2025 Python - Variables 36  Python variables are the reserved memory locations used to store values with in a Python Program.  This means that when you create a variable you reserve some space in the memory.  Based on the data type of a variable, Python interpreter allocates memory and decides what can be stored in the reserved memory  Therefore, by assigning different data types to Python variables, you can store integers, decimals or characters in these variables.  Creating PythonVariables  Python variables do not need explicit declaration to reserve memory space or you can say to create a variable.A Python variable is created automatically when you assign a value to it.The equal sign (=) is used to assign values to variables.  The operand to the left of the = operator is the name of the variable and the operand to the right of the = operator is the value stored in the variable. For example −
  • 37. 03/06/2025 Printing Python Variables 37  Once we create a Python variable and assign a value to it, we can print it using print() function. Following is the extension of previous example and shows how to print different variables in Python:  Here, 100, 1000.0 and "Zara Ali" are the values assigned to counter, miles, and name variables, respectively.When running the above Python program, this produces the following result −
  • 38. 03/06/2025 38  You can delete the reference to a number object by using the del statement.The syntax of the del statement is − del var1[,var2[,var3[....,varN]]]]  You can delete a single object or multiple objects by using the del statement. For example  del var  del var_a, var_b  The Following examples shows how we can delete a variable and if we try to use a deleted variable then Python interpreter will throw an error: Delete aVariable
  • 39. 03/06/2025 Multiple Assignment 39  Python allows you to assign a single value to several variables simultaneously which means you can create multiple variables at a time. For example −  Here, an integer object is created with the value 1, and all three variables are assigned to the same memory location.You can also assign multiple objects to multiple variables. For example −
  • 40. 03/06/2025 Python Variable Names 40  Every Python variable should have a unique name like a, b, c.  A variable name can be meaningful like color, age, name etc.  There are certain rules which should be taken care while naming a Python variable:  A variable name must start with a letter or the underscore character  A variable name cannot start with a number or any special character like $, (, * % etc.  A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )  Python variable names are case-sensitive which means Name and NAME are two different variables in Python.  Python reserved keywords cannot be used naming the variable.
  • 41. 03/06/2025 Cont. 41  Example the following are valid Python variable names:  Example the following are invalid Python variable names:
  • 42. 03/06/2025 Python Local Variable 42  Python LocalVariables are defined inside a function.We can not access variable outside the function.  A Python functions is a piece of reusable code and you will learn more about function in Python - Functions tutorial.  Python GlobalVariable  Any variable created outside a function can be accessed within any function and so they have global scope. Following is an example of global variables:
  • 43. 03/06/2025 Python - Data Types 43  Python DataTypes are used to define the type of a variable. It defines what type of data we are going to store in a variable.  The data stored in memory can be of many types. For example, a person's age is stored as a numeric value and his or her address is stored as alphanumeric characters.  Python has various built-in data types which we will discuss with in this tutorial:  Numeric - int, float, complex  String - str  Sequence - list, tuple, range  Binary - bytes, bytearray, memoryview  Mapping - dict  Boolean - bool  Set - set, frozenset  None - NoneType
  • 44. 03/06/2025 Python Numeric Data Type 44  Python numeric data types store numeric values. Number objects are created when you assign a value to them. For example −  Python supports four different numerical types −  int (signed integers)  long (long integers, they can also be represented in octal and hexadecimal)  float (floating point real values)  complex (complex numbers)
  • 45. 03/06/2025 Examples Here are some examples of numbers − 45  Python allows you to use a lowercase l with long, but it is recommended that you use only an uppercase L to avoid confusion with the number 1. Python displays long integers with an uppercase L.  A complex number consists of an ordered pair of real floating-point numbers denoted by x + yj, where x and y are the real numbers and j is the imaginary unit.
  • 46. 03/06/2025 Following is an example to show the usage of Integer, Float and Complex numbers: 46  Python String DataType  Python Strings are identified as a contiguous set of characters represented in the quotation marks. Python allows for either pairs of single or double quotes. Subsets of strings can be taken using the slice operator ([ ] and [:] ) with indexes starting at 0 in the beginning of the string and working their way from -1 at the end.
  • 47. 03/06/2025 Cont. 47  The plus (+) sign is the string concatenation operator and the asterisk (*) is the repetition operator in Python. For example −  Python List DataType  Python Lists are the most versatile compound data types.A Python list contains items separated by commas and enclosed within square brackets ([]).  To some extent, Python lists are similar to arrays in C. One difference between them is that all the items belonging to a Python list can be of different data type where as C array can store elements related to a particular data type.
  • 48. 03/06/2025 Cont. 48  The values stored in a Python list can be accessed using the slice operator ([ ] and [:]) with indexes starting at 0 in the beginning of the list and working their way to end -1.The plus (+) sign is the list concatenation operator, and the asterisk (*) is the repetition operator. For example −  PythonTuple DataType  Python tuple is another sequence data type that is similar to a list.A Python tuple consists of a number of values separated by commas. Unlike lists, however, tuples are enclosed within parentheses.
  • 49. 03/06/2025 Cont. 49  The main differences between lists and tuples are: Lists are enclosed in brackets ( [ ] ) and their elements and size can be changed, while tuples are enclosed in parentheses ( ( ) ) and cannot be updated. Tuples can be thought of as read-only lists. For example −  The main differences between lists and tuples are: Lists are enclosed in brackets ( [ ] ) and their elements and size can be changed, while tuples are enclosed in parentheses ( ( ) ) and cannot be updated.Tuples can be thought of as read-only lists. For example −
  • 50. 03/06/2025 Cont.. 50  The following code is invalid with tuple, because we attempted to update a tuple, which is not allowed. Similar case is possible with lists −  Python Ranges:  Python range() is an in-built function in Python which returns a sequence of numbers starting from 0 and increments to 1 until it reaches a specified number.  We use range() function with for and while loop to generate a sequence of numbers. Following is the syntax of the function:  Here is the description of the parameters used:  start: Integer number to specify starting position, (Its optional, Default: 0)  stop: Integer number to specify starting position (It's mandatory)  step: Integer number to specify increment, (Its optional, Default: 1) 
  • 51. 03/06/2025 Cont. 51  The Following Examples is a program which uses for loop to print number  from 0 to 4 −  Now let's modify above program to print the number starting from 1 instead of 0:  Python Dictionary  Python dictionaries are kind of hash table type. They work like associative arrays or and consist of key-value pairs. A dictionary key can be almost any Python type hashes found in Perl , but are usually numbers or strings. Values, on the other hand, can be any arbitrary Python object.  Dictionaries are enclosed by curly braces ({ }) and values can be assigned and accessed using square braces ([]). For example −
  • 52. 03/06/2025 Cont. 52   Python dictionaries have no concept of order among elements. It is incorrect to say that the elements are "out of order"; they are simply unordered.
  • 53. 03/06/2025 Python Boolean Data Types 53  Python Boolean type is one of built-in data types which represents one of the two values either True or False. Python bool() function allows you to evaluate the value of any expression and returns either True or False based on the expression.  Following is another program which evaluates the expressions and prints the return values:
  • 54. 03/06/2025 Python Data Type Conversion 54  Sometimes, you may need to perform conversions between the built-in data types.To convert data between different Python data types, you simply use the type name as a function.  Conversion to int  Following is an example to convert number, float and string into integer data type:   Conversion to float: Following is an example to convert number, float and string into float data type:
  • 55. 03/06/2025 Conversion to string 55  example to convert number, float and string into string data type:  DataType Conversion Functions: there are several built-in functions to perform conversion from one data type to another.These functions return a new object representing the converted value.
  • 57. 03/06/2025 Python - Operators 57  Python operators are the constructs which can manipulate the value of operands.These are symbols used for the purpose of logical, arithmetic and various other operations.  Consider the expression 4 + 5 = 9. Here, 4 and 5 are called operands and + is called operator. In this tutorial, we will study different types of Python operators.  Types of Python Operators  Python language supports the following types of operators. • Arithmetic Operators • Comparison (Relational) Operators • Assignment Operators • Logical Operators • Bitwise Operators • Membership Operators • Identity Operators
  • 58. 03/06/2025 Python Arithmetic Operators 58  are used to perform mathematical operations on numerical values. These operations are Addition, Subtraction, Multiplication, Division, Modulus, Exponents and Floor Division. 
  • 59. 03/06/2025 Python Comparison Operators 59  compare the values on either sides of them and decide the relation among them.They are also called relational operators.These operators are equal, not equal, greater than, less than, greater than or equal to and less than or equal to. 
  • 60. 03/06/2025 Python Assignment Operators 60  are used to assign values to variables.These operators include simple assignment operator, addition assign, subtraction assign, multiplication assign, division and assign operators etc.
  • 62. 03/06/2025 Python Bitwise Operators 62  It works on bits and performs bit by bit operation.Assume if a = 60; and b = 13; Now in the binary format their values will be 0011 1100 and 0000 1101 respectively. Following table lists out the bitwise operators supported by Python language with an example each in those, we use the above two variables (a and b) as operands −
  • 64. 03/06/2025 Python Logical Operators 64  There are following logical operators supported by Python language.Assume variable a holds 10 and variable b holds 20 then   Python Membership Operators: Python’s membership operators test for membership in a sequence, such as strings, lists, or tuples. There are two membership operators as explained below −
  • 65. 03/06/2025 Python Identity Operators 65  Identity operators compare the memory locations of two objects.There are two Identity operators explained below −  Python Operators Precedence: the following table lists all operators from highest precedence to lowest.