Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (1 vote)
3K views

internship-REPORT Python

The document summarizes the internship report of Datla Nishitha Varma on programming with Python during the 3rd semester of B.E in Information Technology. It includes an introduction to Python, certificates from the guide and HOD, acknowledgements, abstract on Python features and applications, and contents listing chapters on Python installation, variables, control flows, OOP, GUI with PyQt, applications, and conclusion.

Uploaded by

Pro Tech
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
3K views

internship-REPORT Python

The document summarizes the internship report of Datla Nishitha Varma on programming with Python during the 3rd semester of B.E in Information Technology. It includes an introduction to Python, certificates from the guide and HOD, acknowledgements, abstract on Python features and applications, and contents listing chapters on Python installation, variables, control flows, OOP, GUI with PyQt, applications, and conclusion.

Uploaded by

Pro Tech
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

INTERNSHIP

REPORT

On

PYTHON
B.E (EEE)-III Sem
By

Datla Nishitha varma (160121734076)

Under the guidance of

Sri.C.Harish
Assistant Professor,Dept of IT

DEPARTMENT OF INFORMATION TECHNOLOGY


CHAITANYA BHARATHI INSTITUTE OF TECHNOLOGY (A)
(Affiliated to Osmania University; Accredited by NBA(AICTE) and NAAC(UGC), ISO Certified 9001:2015)
KOKAPET(V),GANDIPET(M), RR District HYDERABAD -75
Website: www.cbit.ac.in

2022-2023

1
CERTIFICATE
This is to certify that the internship entitled “Programming with Python” submitted to
CHAITANYA BHARATHI INSTITUTE OF TECHNOLOGY, in partial fulfillment of
the requirements for the award of the completion of III semester of B.E in Information
Technology, during the academic year 2022-2023, is a record of original work done by
DATLA NISHITHA VARMA(160121734076) during the period of study in Department
of EEE, CBIT, HYDERABAD, under our guidance.

Internship Guide Head of the Department


Sri.C.Harish Dr.G.SURESH BABU
Assistant Professor, Dept. of EEE. Professor, Dept. of EEE.
CBIT, Hyderabad. CBIT, Hyderabad.

2
ACKNOWLEDGEMENT

We would like to express our heartfelt gratitude to Sri.C.Harish, Assistant Professor of


EEE department, our internship guide, for his invaluable guidance and constant support,
along with his capable instruction and persistent encouragement.

We are grateful to our Head of Department, Dr.G.Suresh Babu, for her steady support
and for the provision of every resource required for the completion of this project.

We would like to take this opportunity to thank our Principal, Dr.P.RAVINDAR


REDDY, as well as the management of the institute, for having designed an excellent
learning atmosphere.

3
ABSTRACT
Python is a modern, easy-to-learn, object-oriented programming language. It has a powerful set of
built-in data types and easy-to-use control constructs. Since Python is an interpreted language, it is
most easily reviewed by simply looking at and describing interactive sessions. It is used in vast
number of applications due to the various standard libraries that come along with it and its capacity to
integrate with other languages and use their features. Python can be used for scripting, web scraping,
and creating data sets. It’s popular in the scientific community for scientific computing; there are
libraries that make it easy to share academic code projects in Python. Python is a web programming
language, so it interfaces with the internet. It knows how to receive and send web requests and talk to
databases. This paper describes the main features of Python programming, loops and control
statements in python then discusses applications of Python programming.

4
CONTENTS

S.no Topics Page.


No

Title page 1

Certificate 2

Acknowledgement 3

Abstract 4

Contents 5

1 Introduction 6
1.1Installation of python 6
1.2Salient features of python 7
1.3Basic syntax of phython 8

2 Usingbvariables in python 9
2.1 Numeric datatypes 9
2.2 String datatypes 10
2.3 Lists 13
3 Basics of programming of python 19
3.1 Using loops and conditionals

4 Principles of Object-Oriented programming(OOP) 22

4.1 Overview of OOP 22


4.2 Declaring class and creating objects 33
4.3 Understanding inheritance
34

5 Developing a GUI with pyQT 36


5.1 QT designer

6 Applications 38

7 Conclusion 40

5
1. INTRODUCTION

1.1 Installing python

1. Open a browser to the Python website and download the Windows installer.

2. Double click on the downloaded file and install Python for all users, and ensure that Python is added to your
path. Click on Install now to begin. Adding Python to the path will enable us to use the Python interpreter from
any part of the filesystem.

6
3. After the installation is complete, click Disable path length limit and then Close. Disabling the path length
limit means we can use more than 260 characters in a file path.

4. Click Close to end the installation.

1.2 Salient features of python

1. Free and Open Source

Python language is freely available at the official website and you can download it from the given download link
below click on the Download Python keyword. Download Python Since it is open-source, this means that source code
is also available to the public. So you can download it, use it as well as share it.

2. Easy to code

Python is a high-level programming language. Python is very easy to learn the language as compared to other
languages like C, C#, Javascript, Java, etc. It is very easy to code in the Python language and anybody can learn Python
basics in a few hours or days. It is also a developer-friendly language.

3. Easy to Read

As you will see, learning Python is quite simple. As was already established, Python’s syntax is really straightforward.
The code block is defined by the indentations rather than by semicolons or brackets.

4. Object-Oriented Language

One of the key features of Python is Object-Oriented programming. Python supports object-oriented language and
concepts of classes, object encapsulation, etc.

5. GUI Programming Support

Graphical User interfaces can be made using a module such as PyQt5, PyQt4, wxPython, or Tk in python. PyQt5 is the
most popular option for creating graphical apps with Python.

6. High-Level Language

7
Python is a high-level language. When we write programs in Python, we do not need to remember the system
architecture, nor do we need to manage the memory.

7. Extensible feature

Python is an Extensible language. We can write some Python code into C or C++ language and also we can compile
that code in C/C++ language.

8. Easy to Debug

Excellent information for mistake tracing. You will be able to quickly identify and correct the majority of your
program’s issues once you understand how to interpret Python’s error traces. Simply by glancing at the code, you can
determine what it is designed to perform.

9. Python is a Portable language

Python language is also a portable language. For example, if we have Python code for windows and if we want to run
this code on other platforms such as Linux, Unix, and Mac then we do not need to change it, we can run this code on
any platform.

10. Python is an Integrated language

Python is also an Integrated language because we can easily integrate Python with other languages like C, C++, etc.

1.3 Basic Syntax of Python

8
2.Using variables in python

2.1 Numeric Datatypes

The interpreter acts as a simple calculator: you can type an expression at it and it will write the value. Expression
syntax is straightforward: the operators +, -, * and / work just like in most other languages (for example, Pascal or
C); parentheses (()) can be used for grouping. For example:

>>> 2 + 2
4
>>> 50 - 5*6
20
>>> (50 - 5*6) / 4
5.0
>>> 8 / 5
# division always returns a floating point number
1.6
The integer numbers (e.g. 2, 4, 20) have type int, the ones with a fractional part (e.g. 5.0, 1.6) have type
float. We will see more about numeric types later in the tutorial.
Division (/) always returns a float. To do floor division and get an integer result you can use the // operator; to
calculate the remainder you can use %:
9Python Tutorial, Release 3.11.2
>>> 17 / 3
# classic division returns a float
5.666666666666667
>>>
>>> 17 // 3
# floor division discards the fractional part
5
>>> 17 % 3
# the % operator returns the remainder of the division
2
>>> 5 * 3 + 2
# floored quotient * divisor + remainder
17
With Python, it is possible to use the ** operator to calculate powers1:
>>> 5 ** 2
# 5 squared
25
>>> 2 ** 7
# 2 to the power of 7
128
The equal sign (=) is used to assign a value to a variable. Afterwards, no result is displayed before the next interactive
prompt:
>>> width = 20
>>> height = 5 * 9
>>> width * height
900
If a variable is not “defined” (assigned a value), trying to use it will give you an error:
>>> n
# try to access an undefined variable
Traceback (most recent call last):
File "<stdin>", line 1, in <module> NameError: name 'n' is not defined There is full support for floating point; operators
with mixed type operands convert the integer operand to floating point:
>>> 4 * 3.75 - 1
14.0
In interactive mode, the last printed expression is assigned to the variable _. This means that when you are using Python as
a desk calculator, it is somewhat easier to continue calculations, for example:
>>> tax = 12.5 / 100
9
>>> price = 100.50
>>> price * tax
12.5625
>>> price + _
113.0625
>>> round(_, 2)
113.06
This variable should be treated as read-only by the user. Don’t explicitly assign a value to it — you would create an
independent local variable with the same name masking the built-in variable with its magic behavior. In addition to int and
float, Python supports other types of numbers, such as Decimal and Fraction. Python also has built-in support for complex
numbers, and uses the j or J suffix to indicate the imaginary part (e.g. 3+5j).
2.2 String Datatypes
Besides numbers, Python can also manipulate strings, which can be expressed in several ways. They can be enclosed
in single quotes ('...') or double quotes ("...") with the same result2. \ can be used to escape quotes:
>>> 'spam eggs'
# single quotes
'spam eggs'
>>> 'doesn\'t'
# use \' to escape the single quote...
"doesn't"
>>> "doesn't"
# ...or use double quotes instead
"doesn't"
>>> '"Yes," they said.'
'"Yes," they said.'
>>> "\"Yes,\" they said."
'"Yes," they said.'
>>> '"Isn\'t," they said.'
'"Isn\'t," they said.'
In the interactive interpreter, the output string is enclosed in quotes and special characters are escaped with back
slashes. While this might sometimes look different from the input (the enclosing quotes could change), the two strings
are equivalent. The string is enclosed in double quotes if the string contains a single quote and no double quotes,
otherwise it is enclosed in single quotes. The print() function produces a more readable output, by omitting the
enclosing quotes and by printing escaped and special characters:
>>> '"Isn\'t," they said.'
'"Isn\'t," they said.'
>>> print('"Isn\'t," they said.')
"Isn't," they said.
>>> s = 'First line.\nSecond line.'
# \n means newline
>>> s
# without print(), \n is included in the output
'First line.\nSecond line.'
>>> print(s)
# with print(), \n produces a new line
First line.
Second line.
If you don’t want characters prefaced by \ to be interpreted as special characters, you can use raw strings by adding
an r before the first quote:
>>> print('C:\some\name')
# here \n means newline!
C:\some
ame
>>> print(r'C:\some\name')
# note the r before the quote
C:\some\name
There is one subtle aspect to raw strings: a raw string may not end in an odd number of \ characters; see the FAQ
entry for more information and workarounds.
String literals can span multiple lines. One way is using triple-quotes: """...""" or '''...'''. End of lines
are automatically included in the string, but it’s possible to prevent this by adding a \ at the end of the line. The
10
following example:
print("""\
Usage: thingy [OPTIONS]
-h
Display this usage message
-H hostname
Hostname to connect to
""")
produces the following output (note that the initial newline is not included):
2 Unlike other languages, special characters such as \n have the same meaning with both single ('...') and double ("...")
quotes. The
only difference between the two is that within single quotes you don’t need to escape " (but you have to escape \') and vice
versa.
3.1. Using Python as a Calculator
11Python Tutorial, Release 3.11.2
Usage: thingy [OPTIONS]
-h
Display this usage message
-H hostname
Hostname to connect to
Strings can be concatenated (glued together) with the + operator, and repeated with *:
>>> # 3 times 'un', followed by 'ium'
>>> 3 * 'un' + 'ium'
'unununium'
Two or more string literals (i.e. the ones enclosed between quotes) next to each other are automatically concatenated.
>>> 'Py' 'thon'
'Python'
This feature is particularly useful when you want to break long strings:
>>> text = ('Put several strings within parentheses '
...
'to have them joined together.')
>>> text
'Put several strings within parentheses to have them joined together.'
This only works with two literals though, not with variables or expressions:
>>> prefix = 'Py'
>>> prefix 'thon'
# can't concatenate a variable and a string literal
File "<stdin>", line 1
prefix 'thon'
^^^^^^
SyntaxError: invalid syntax
>>> ('un' * 3) 'ium'
File "<stdin>", line 1
('un' * 3) 'ium'
^^^^^
SyntaxError: invalid syntax
If you want to concatenate variables or a variable and a literal, use +:
>>> prefix + 'thon'
'Python'
Strings can be indexed (subscripted), with the first character having index 0. There is no separate character type; a
character is simply a string of size one:
>>> word = 'Python'
>>> word[0]
# character in position 0
'P'
>>> word[5]
# character in position 5
'n'
Indices may also be negative numbers, to start counting from the right:
>>> word[-1]
# last character
11
'n'
>>> word[-2]
# second-last character
'o'
>>> word[-6]
'P'
Note that since -0 is the same as 0, negative indices start from -1.
In addition to indexing, slicing is also supported. While indexing is used to obtain individual characters, slicing allows
you to obtain substring:
12
Chapter 3. An Informal Introduction to PythonPython Tutorial, Release 3.11.2
>>> word[0:2]
# characters from position 0 (included) to 2 (excluded)
'Py'
>>> word[2:5]
# characters from position 2 (included) to 5 (excluded)
'tho'
Slice indices have useful defaults; an omitted first index defaults to zero, an omitted second index defaults to the size
of the string being sliced.
>>> word[:2]
# character from the beginning to position 2 (excluded)
'Py'
>>> word[4:]
# characters from position 4 (included) to the end
'on'
>>> word[-2:]
# characters from the second-last (included) to the end
'on'
Note how the start is always included, and the end always excluded. This makes sure that s[:i] + s[i:] is
always equal to s:
>>> word[:2] + word[2:]
'Python'
>>> word[:4] + word[4:]
'Python'
One way to remember how slices work is to think of the indices as pointing between characters, with the left edge of
the first character numbered 0. Then the right edge of the last character of a string of n characters has index n, for
example:
+---+---+---+---+---+---+
|P|y|t|h|o|n|
+---+---+---+---+---+---+
0
1
2
3
4
5
6
-6
-5
-4
-3
-2
-1
The first row of numbers gives the position of the indices 0…6 in the string; the second row gives the corresponding
negative indices. The slice from i to j consists of all characters between the edges labeled i and j, respectively.
For non-negative indices, the length of a slice is the difference of the indices, if both are within bounds. For example,
the length of word[1:3] is 2.
Attempting to use an index that is too large will result in an error:
>>> word[42]
# the word only has 6 characters
Traceback (most recent call last):
12
File "<stdin>", line 1, in <module>
IndexError: string index out of range
However, out of range slice indexes are handled gracefully when used for slicing:
>>> word[4:42]
'on'
>>> word[42:]
''
Python strings cannot be changed — they are immutable. Therefore, assigning to an indexed position in the string
results in an error:
>>> word[0] = 'J'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object does not support item assignment
>>> word[2:] = 'py'
Traceback (most recent call last):
(continues on next page)
3.1. Using Python as a Calculator
13Python Tutorial, Release 3.11.2
(continued from previous page)
File "<stdin>", line 1, in <module>
TypeError: 'str' object does not support item assignment
If you need a different string, you should create a new one:
>>> 'J' + word[1:]
'Jython'
>>> word[:2] + 'py'
'Pypy'
The built-in function len() returns the length of a string:
>>> s = 'supercalifragilisticexpialidocious'
>>> len(s)
34
2.3 Lists
Python Lists are just like dynamically sized arrays, declared in other languages (vector in C++ and ArrayList in Java).
In simple language, a list is a collection of things, enclosed in [ ] and separated by commas.
The list is a sequence data type which is used to store the collection of data. Tuples and String are
other types of sequence data types.
Example of list in Python
Here we are creating Python List using [].

 Python3

Var = ["Geeks", "for", "Geeks"]


print(Var)

Output:
["Geeks", "for", "Geeks"]
Lists are the simplest containers that are an integral part of the Python language. Lists need not be homogeneous
always which makes it the most powerful tool in Python. A single list may contain DataTypes like Integers, Strings, as
well as Objects. Lists are mutable, and hence, they can be altered even after their creation.
Creating a List in Python
Lists in Python can be created by just placing the sequence inside the square brackets[]. Unlike Sets, a list doesn’t need
a built-in function for its creation of a list.
Note: Unlike Sets, the list may contain mutable elements.

Example 1: Creating a list in Python

 Python3
13
# Python program to demonstrate
# Creation of List

# Creating a List
List = []
print("Blank List: ")
print(List)

# Creating a List of numbers


List = [10, 20, 14]
print("\nList of numbers: ")
print(List)

# Creating a List of strings and accessing


# using index
List = ["Geeks", "For", "Geeks"]
print("\nList Items: ")
print(List[0])
print(List[2])

Output
Blank List:
[]

List of numbers:
[10, 20, 14]

List Items:
Geeks
Geeks
Complexities for Creating Lists
Time Complexity: O(1)
Space Complexity: O(n)

Example 2: Creating a list with multiple distinct or duplicate elements

A list may contain duplicate values with their distinct positions and hence, multiple distinct or duplicate values can be
passed as a sequence at the time of list creation.

 Python3

# Creating a List with


# the use of Numbers
# (Having duplicate values)
List = [1, 2, 4, 4, 3, 3, 3, 6, 5]
print("\nList with the use of Numbers: ")
print(List)

# Creating a List with


# mixed type of values

14
# (Having numbers and strings)
List = [1, 2, 'Geeks', 4, 'For', 6, 'Geeks']
print("\nList with the use of Mixed Values: ")
print(List)

Output
List with the use of Numbers:
[1, 2, 4, 4, 3, 3, 3, 6, 5]

List with the use of Mixed Values:


[1, 2, 'Geeks', 4, 'For', 6, 'Geeks']
Accessing elements from the List
In order to access the list items refer to the index number. Use the index operator [ ] to access an item in a list. The
index must be an integer. Nested lists are accessed using nested indexing.
Example 1: Accessing elements from list

 Python3

# Python program to demonstrate


# accessing of element from list

# Creating a List with


# the use of multiple values
List = ["Geeks", "For", "Geeks"]

# accessing a element from the


# list using index number
print("Accessing a element from the list")
print(List[0])
print(List[2])

Output
Accessing a element from the list
Geeks
Geeks
Example 2: Accessing elements from a multi-dimensional list

 Python3

# Creating a Multi-Dimensional List


# (By Nesting a list inside a List)
List = [['Geeks', 'For'], ['Geeks']]

# accessing an element from the


# Multi-Dimensional List using
# index number
print("Accessing a element from a Multi-Dimensional list")
print(List[0][1])
print(List[1][0])

Output
Accessing a element from a Multi-Dimensional list
For
15
Geeks

Negative indexing

In Python, negative sequence indexes represent positions from the end of the array. Instead of having to compute the
offset as in List[len(List)-3], it is enough to just write List[-3]. Negative indexing means beginning from the end, -1
refers to the last item, -2 refers to the second-last item, etc.

 Python3

List = [1, 2, 'Geeks', 4, 'For', 6, 'Geeks']

# accessing an element using


# negative indexing
print("Accessing element using negative indexing")

# print the last element of list


print(List[-1])

# print the third last element of list


print(List[-3])

Output
Accessing element using negative indexing
Geeks
For
Complexities for Accessing elements in a Lists:
Time Complexity: O(1)
Space Complexity: O(1)
Getting the size of Python list
Python len() is used to get the length of the list.

 Python3

# Creating a List
List1 = []
print(len(List1))

# Creating a List of numbers


List2 = [10, 20, 14]
print(len(List2))

Output
0
3
Taking Input of a Python List
We can take the input of a list of elements as string, integer, float, etc. But the default one is a string.

Example 1:

 Python3

# Python program to take space

16
# separated input as a string
# split and store it to a list
# and print the string list

# input the list as string


string = input("Enter elements (Space-Separated): ")

# split the strings and store it to a list


lst = string.split()
print('The list is:', lst) # printing the list

Output:
Enter elements: GEEKS FOR GEEKS
The list is: ['GEEKS', 'FOR', 'GEEKS']
Example 2:

 Python

# input size of the list


n = int(input("Enter the size of list : "))
# store integers in a list using map,
# split and strip functions
lst = list(map(int, input("Enter the integer\
elements:").strip().split()))[:n]

# printing the list


print('The list is:', lst)

Output:
Enter the size of list : 4
Enter the integer elements: 6 3 9 10
The list is: [6, 3, 9, 10]
To know more see this.
Adding Elements to a Python List

Method 1: Using append() method

Elements can be added to the List by using the built-in append() function. Only one element at a time can be added to
the list by using the append() method, for the addition of multiple elements with the append() method, loops are used.
Tuples can also be added to the list with the use of the append method because tuples are immutable. Unlike Sets, Lists
can also be added to the existing list with the use of the append() method.

 Python3

# Python program to demonstrate


# Addition of elements in a List

# Creating a List
List = []
print("Initial blank List: ")
print(List)

17
# Addition of Elements
# in the List
List.append(1)
List.append(2)
List.append(4)
print("\nList after Addition of Three elements: ")
print(List)

# Adding elements to the List


# using Iterator
for i in range(1, 4):
List.append(i)
print("\nList after Addition of elements from 1-3: ")
print(List)

# Adding Tuples to the List


List.append((5, 6))
print("\nList after Addition of a Tuple: ")
print(List)

# Addition of List to a List


List2 = ['For', 'Geeks']
List.append(List2)
print("\nList after Addition of a List: ")
print(List)

Output
Initial blank List:
[]

List after Addition of Three elements:


[1, 2, 4]

List after Addition of elements from 1-3:


[1, 2, 4, 1, 2, 3]

List after Addition of a Tuple:


[1, 2, 4, 1, 2, 3, (5, 6)]

List after Addition of a List:


[1, 2, 4, 1, 2, 3, (5, 6), ['For', 'Geeks']]
Complexities for Adding elements in a Lists(append() method):
Time Complexity: O(1)
Space Complexity: O(1)

18
3.Basics of programming of python

3.1 Using Loops and Conditionals


if Statements
Perhaps the most well-known statement type is the if statement. For example:
>>> x = int(input("Please enter an integer: "))
Please enter an integer: 42
>>> if x < 0:
...
x=0
...
print('Negative changed to zero')
... elif x == 0:
...
print('Zero')
... elif x == 1:
...
print('Single')
... else:
...
print('More')
...
More
There can be zero or more elif parts, and the else part is optional. The keyword ‘elif’ is short for ‘else if’, and
is useful to avoid excessive indentation. An if … elif … elif … sequence is a substitute for the switch or
case statements found in other languages.
If you’re comparing the same value to several constants, or checking for specific types or attributes, you may also find
the match statement useful. For more details see match Statements.
for Statements
The for statement in Python differs a bit from what you may be used to in C or Pascal. Rather than always iterating
over an arithmetic progression of numbers (like in Pascal), or giving the user the ability to define both the iteration
step and halting condition (as C), Python’s for statement iterates over the items of any sequence (a list or a string),
in the order that they appear in the sequence. For example (no pun intended):
>>> # Measure some strings:
... words = ['cat', 'window', 'defenestrate']
>>> for w in words:
...
print(w, len(w))
...
cat 3
window 6
defenestrate 12
17Python Tutorial, Release 3.11.2
Code that modifies a collection while iterating over that same collection can be tricky to get right. Instead, it is usually
more straight-forward to loop over a copy of the collection or to create a new collection:
# Create a sample collection
users = {'Hans': 'active', 'Éléonore': 'inactive', ': 'active'}
# Strategy: Iterate over a copy
for user, status in users.copy().items():
if status == 'inactive':
del users[user]
# Strategy: Create a new collection
active_users = {}
for user, status in users.items():
if status == 'active':
active_users[user] = status
The range() Function
If you do need to iterate over a sequence of numbers, the built-in function range() comes in handy. It generates

19
arithmetic progressions:
>>> for i in range(5):
...
print(i)
...
0
1
2
3
4
The given end point is never part of the generated sequence; range(10) generates 10 values, the legal indices for
items of a sequence of length 10. It is possible to let the range start at another number, or to specify a different
increment (even negative; sometimes this is called the ‘step’):
>>> list(range(5, 10))
[5, 6, 7, 8, 9]
>>> list(range(0, 10, 3))
[0, 3, 6, 9]
>>> list(range(-10, -100, -30))
[-10, -40, -70]
To iterate over the indices of a sequence, you can combine range() and len() as follows:
>>> a = ['Mary', 'had', 'a', 'little', 'lamb']
>>> for i in range(len(a)):
...
print(i, a[i])
...
0 Mary
1 had
2a
3 little
4 lamb
In most such cases, however, it is convenient to use the enumerate() function, see Looping Techniques.
A strange thing happens if you just print a range:
18
Chapter 4. More Control Flow ToolsPython Tutorial, Release 3.11.2
>>> range(10)
range(0, 10)
In many ways the object returned by range() behaves as if it is a list, but in fact it isn’t. It is an object which returns
the successive items of the desired sequence when you iterate over it, but it doesn’t really make the list, thus saving
space.
We say such an object is iterable, that is, suitable as a target for functions and constructs that expect something from
which they can obtain successive items until the supply is exhausted. We have seen that the for statement is such a
construct, while an example of a function that takes an iterable is sum():
>>> sum(range(4))
#0+1+2+3
6
Later we will see more functions that return iterables and take iterables as arguments. In chapter Data Structures, we
will discuss in more detail about list().
break and continue Statements, and else Clauses on Loops
The break statement, like in C, breaks out of the innermost enclosing for or while loop.
Loop statements may have an else clause; it is executed when the loop terminates through exhaustion of the iterable
(with for) or when the condition becomes false (with while), but not when the loop is terminated by a break
statement. This is exemplified by the following loop, which searches for prime numbers:
>>> for n in range(2, 10):
...
for x in range(2, n):
...
if n % x == 0:
...
print(n, 'equals', x, '*', n//x)
...
break
20
...
else:
...
# loop fell through without finding a factor
...
print(n, 'is a prime number')
...
2 is a prime number
3 is a prime number
4 equals 2 * 2
5 is a prime number
6 equals 2 * 3
7 is a prime number
8 equals 2 * 4
9 equals 3 * 3
(Yes, this is the correct code. Look closely: the else clause belongs to the for loop, not the if statement.)
When used with a loop, the else clause has more in common with the else clause of a try statement than it does
with that of if statements: a try statement’s else clause runs when no exception occurs, and a loop’s else clause
runs when no break occurs. For more on the try statement and exceptions, see Handling Exceptions.
The continue statement, also borrowed from C, continues with the next iteration of the loop:
>>> for num in range(2, 10):
...
if num % 2 == 0:
...
print("Found an even number", num)
...
continue
...
print("Found an odd number", num)
...
Found an even number 2
Found an odd number 3
Found an even number 4
(continues on next page)
4.4. break and continue Statements, and else Clauses on Loops
19Python Tutorial, Release 3.11.2
(continued from previous page)
Found an odd number 5
Found an even number 6
Found an odd number 7
Found an even number 8
Found an odd number 9

21
4.Principles of Object-oriented Programming(OOP)
4.1 Overview of OOP
Main Concepts of Object-Oriented Programming (OOPs)
 Class
 Objects
 Polymorphism
 Encapsulation
 Inheritance
 Data Abstraction

OOPs
Class
A class is a collection of objects. A class contains the blueprints or the prototype from which the objects are being
created. It is a logical entity that contains some attributes and methods.
To understand the need for creating a class let’s consider an example, let’s say you wanted to track the number of dogs
that may have different attributes like breed, age. If a list is used, the first element could be the dog’s breed while the
second element could represent its age. Let’s suppose there are 100 different dogs, then how would you know which
element is supposed to be which? What if you wanted to add other properties to these dogs? This lacks organization
and it’s the exact need for classes.
Some points on Python class:
 Classes are created by keyword class.
 Attributes are the variables that belong to a class.
 Attributes are always public and can be accessed using the dot (.) operator. Eg.: Myclass.Myattribute
Class Definition Syntax:
class ClassName:
# Statement-1
.
.
.
# Statement-N

Example: Creating an empty Class in Python

 Python

22
# Python3 program to
# demonstrate defining
# a class

class Dog:
pass

In the above example, we have created a class named dog using the class keyword.
Objects
The object is an entity that has a state and behavior associated with it. It may be any real-world object like a mouse,
keyboard, chair, table, pen, etc. Integers, strings, floating-point numbers, even arrays, and dictionaries, are all objects.
More specifically, any single integer or any single string is an object. The number 12 is an object, the string “Hello,
world” is an object, a list is an object that can hold other objects, and so on. You’ve been using objects all along and
may not even realize it.
An object consists of :
 State: It is represented by the attributes of an object. It also reflects the properties of an object.
 Behavior: It is represented by the methods of an object. It also reflects the response of an object to other
objects.
 Identity: It gives a unique name to an object and enables one object to interact with other objects.
To understand the state, behavior, and identity let us take the example of the class dog (explained above).
 The identity can be considered as the name of the dog.
 State or Attributes can be considered as the breed, age, or color of the dog.
 The behavior can be considered as to whether the dog is eating or sleeping.

Example: Creating an object

 Python3

obj = Dog()

This will create an object named obj of the class Dog defined above. Before diving deep into objects and class let us
understand some basic keywords that will we used while working with objects and classes.

The self

1. Class methods must have an extra first parameter in the method definition. We do not give a value for this
parameter when we call the method, Python provides it
2. If we have a method that takes no arguments, then we still have to have one argument.
3. This is similar to this pointer in C++ and this reference in Java.
When we call a method of this object as myobject.method(arg1, arg2), this is automatically converted by Python into
MyClass.method(myobject, arg1, arg2) – this is all the special self is about.
Note: For more information, refer to self in Python class

The __init__ method

The __init__ method is similar to constructors in C++ and Java. It is run as soon as an object of a class is instantiated.
The method is useful to do any initialization you want to do with your object.
Now let us define a class and create some objects using the self and __init__ method.

Example 1: Creating a class and object with class and instance attributes

 Python3

23
class Dog:

# class attribute
attr1 = "mammal"

# Instance attribute
def __init__(self, name):
self.name = name

# Driver code
# Object instantiation
Rodger = Dog("Rodger")
Tommy = Dog("Tommy")

# Accessing class attributes


print("Rodger is a {}".format(Rodger.__class__.attr1))
print("Tommy is also a {}".format(Tommy.__class__.attr1))

# Accessing instance attributes


print("My name is {}".format(Rodger.name))
print("My name is {}".format(Tommy.name))

Output
Rodger is a mammal
Tommy is also a mammal
My name is Rodger
My name is Tommy

Example 2: Creating Class and objects with methods

 Python3

class Dog:

# class attribute
attr1 = "mammal"

# Instance attribute
def __init__(self, name):
self.name = name

def speak(self):
print("My name is {}".format(self.name))

# Driver code
# Object instantiation
Rodger = Dog("Rodger")
Tommy = Dog("Tommy")

# Accessing class methods


Rodger.speak()
Tommy.speak()

Output
24
My name is Rodger
My name is Tommy
Note: For more information, refer Python Classes and Objects
Inheritance
Inheritance is the capability of one class to derive or inherit the properties from another class. The class that derives
properties is called the derived class or child class and the class from which the properties are being derived is called
the base class or parent class. The benefits of inheritance are:
 It represents real-world relationships well.
 It provides the reusability of a code. We don’t have to write the same code again and again. Also, it allows us
to add more features to a class without modifying it.
 It is transitive in nature, which means that if class B inherits from another class A, then all the subclasses of B
would automatically inherit from class A.
Types of Inheritance –
Single Inheritance:
Single-level inheritance enables a derived class to inherit characteristics from a single-parent class.
Multilevel Inheritance:
Multi-level inheritance enables a derived class to inherit properties from an immediate parent class which in turn
inherits properties from his parent class.
Hierarchical Inheritance:
Hierarchical level inheritance enables more than one derived class to inherit properties from a parent class.
Multiple Inheritance:
Multiple level inheritance enables one derived class to inherit properties from more than one base class.

Example: Inheritance in Python

 Python3

# Python code to demonstrate how parent constructors


# are called.

# parent class
class Person(object):

# __init__ is known as the constructor


def __init__(self, name, idnumber):
self.name = name
self.idnumber = idnumber

def display(self):
print(self.name)
print(self.idnumber)

def details(self):
print("My name is {}".format(self.name))
print("IdNumber: {}".format(self.idnumber))

# child class
class Employee(Person):
def __init__(self, name, idnumber, salary, post):
self.salary = salary
self.post = post

25
# invoking the __init__ of the parent class
Person.__init__(self, name, idnumber)

def details(self):
print("My name is {}".format(self.name))
print("IdNumber: {}".format(self.idnumber))
print("Post: {}".format(self.post))

# creation of an object variable or an instance


a = Employee('Rahul', 886012, 200000, "Intern")

# calling a function of the class Person using


# its instance
a.display()
a.details()

Output
Rahul
886012
My name is Rahul
IdNumber: 886012
Post: Intern
In the above article, we have created two classes i.e. Person (parent class) and Employee (Child Class). The Employee
class inherits from the Person class. We can use the methods of the person class through employee class as seen in the
display function in the above code. A child class can also modify the behavior of the parent class as seen through the
details() method.
Note: For more information, refer to our Inheritance in Python tutorial.
Polymorphism
Polymorphism simply means having many forms. For example, we need to determine if the given species of birds fly
or not, using polymorphism we can do this using a single function.

Example: Polymorphism in Python

 Python3

class Bird:

def intro(self):
print("There are many types of birds.")

def flight(self):
print("Most of the birds can fly but some cannot.")

class sparrow(Bird):

def flight(self):
print("Sparrows can fly.")

class ostrich(Bird):

def flight(self):

26
print("Ostriches cannot fly.")

obj_bird = Bird()
obj_spr = sparrow()
obj_ost = ostrich()

obj_bird.intro()
obj_bird.flight()

obj_spr.intro()
obj_spr.flight()

obj_ost.intro()
obj_ost.flight()

Output
There are many types of birds.
Most of the birds can fly but some cannot.
There are many types of birds.
Sparrows can fly.
There are many types of birds.
Ostriches cannot fly.
Note: For more information, refer to our Polymorphism in Python Tutorial.
Encapsulation
Encapsulation is one of the fundamental concepts in object-oriented programming (OOP). It describes the idea of
wrapping data and the methods that work on data within one unit. This puts restrictions on accessing variables and
methods directly and can prevent the accidental modification of data. To prevent accidental change, an object’s
variable can only be changed by an object’s method. Those types of variables are known as private variables.
A class is an example of encapsulation as it encapsulates all the data that is member functions, variables, etc.

Example: Encapsulation in Python

 Python3

# Python program to
# demonstrate private members

# Creating a Base class


class Base:
def __init__(self):
self.a = "GeeksforGeeks"
self.__c = "GeeksforGeeks"

27
# Creating a derived class
class Derived(Base):
def __init__(self):

# Calling constructor of
# Base class
Base.__init__(self)
print("Calling private member of base class: ")
print(self.__c)

# Driver code
obj1 = Base()
print(obj1.a)

# Uncommenting print(obj1.c) will


# raise an AttributeError

# Uncommenting obj2 = Derived() will


# also raise an AtrributeError as
# private member of base class
# is called inside derived class

Output
GeeksforGeeks
In the above example, we have created the c variable as the private attribute. We cannot even access this attribute
directly and can’t even change its value.
Note: for more information, refer to our Encapsulation in Python Tutorial.
Data Abstraction
It hides the unnecessary code details from the user. Also, when we do not want to give out sensitive parts of our code
implementation and this is where data abstraction came.
Data Abstraction in Python can be achieved through creating abstract classes.
Object Oriented Programming in Python | Set 2 (Data Hiding and Object Printing)
https://youtu.be/CiH7lN4
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed
above
Main Concepts of Object-Oriented Programming (OOPs)
 Class
 Objects
 Polymorphism
 Encapsulation
 Inheritance
 Data Abstraction

28
OOPs
Class
A class is a collection of objects. A class contains the blueprints or the prototype from which the objects are being
created. It is a logical entity that contains some attributes and methods.
To understand the need for creating a class let’s consider an example, let’s say you wanted to track the number of dogs
that may have different attributes like breed, age. If a list is used, the first element could be the dog’s breed while the
second element could represent its age. Let’s suppose there are 100 different dogs, then how would you know which
element is supposed to be which? What if you wanted to add other properties to these dogs? This lacks organization
and it’s the exact need for classes.
Some points on Python class:
 Classes are created by keyword class.
 Attributes are the variables that belong to a class.
 Attributes are always public and can be accessed using the dot (.) operator. Eg.: Myclass.Myattribute
Class Definition Syntax:
class ClassName:
# Statement-1
.
.
# Statement-N

Example: Creating an empty Class in Python

 Python

# Python3 program to
# demonstrate defining
# a class

class Dog:
pass

In the above example, we have created a class named dog using the class keyword.
Objects

29
The object is an entity that has a state and behavior associated with it. It may be any real-world object like a mouse,
keyboard, chair, table, pen, etc. Integers, strings, floating-point numbers, even arrays, and dictionaries, are all objects.
More specifically, any single integer or any single string is an object. The number 12 is an object, the string “Hello,
world” is an object, a list is an object that can hold other objects, and so on. You’ve been using objects all along and
may not even realize it.
An object consists of :
 State: It is represented by the attributes of an object. It also reflects the properties of an object.
 Behavior: It is represented by the methods of an object. It also reflects the response of an object to other
objects.
 Identity: It gives a unique name to an object and enables one object to interact with other objects.
To understand the state, behavior, and identity let us take the example of the class dog (explained above).
 The identity can be considered as the name of the dog.
 State or Attributes can be considered as the breed, age, or color of the dog.
 The behavior can be considered as to whether the dog is eating or sleeping.

Example: Creating an object

 Python3

obj = Dog()

This will create an object named obj of the class Dog defined above. Before diving deep into objects and class let us
understand some basic keywords that will we used while working with objects and classes.

The self

1. Class methods must have an extra first parameter in the method definition. We do not give a value for this
parameter when we call the method, Python provides it
2. If we have a method that takes no arguments, then we still have to have one argument.
3. This is similar to this pointer in C++ and this reference in Java.
When we call a method of this object as myobject.method(arg1, arg2), this is automatically converted by Python into
MyClass.method(myobject, arg1, arg2) – this is all the special self is about.
Note: For more information, refer to self in Python class

The __init__ method

The __init__ method is similar to constructors in C++ and Java. It is run as soon as an object of a class is instantiated.
The method is useful to do any initialization you want to do with your object.
Now let us define a class and create some objects using the self and __init__ method.
Inheritance
Inheritance is the capability of one class to derive or inherit the properties from another class. The class that derives
properties is called the derived class or child class and the class from which the properties are being derived is called
the base class or parent class. The benefits of inheritance are:
 It represents real-world relationships well.
 It provides the reusability of a code. We don’t have to write the same code again and again. Also, it allows us
to add more features to a class without modifying it.
 It is transitive in nature, which means that if class B inherits from another class A, then all the subclasses of B
would automatically inherit from class A.
Types of Inheritance –
Single Inheritance:
Single-level inheritance enables a derived class to inherit characteristics from a single-parent class.

30
Multilevel Inheritance:
Multi-level inheritance enables a derived class to inherit properties from an immediate parent class which in turn
inherits properties from his parent class.
Hierarchical Inheritance:
Hierarchical level inheritance enables more than one derived class to inherit properties from a parent class.
Multiple Inheritance:
Multiple level inheritance enables one derived class to inherit properties from more than one base class.
Polymorphism
Polymorphism simply means having many forms. For example, we need to determine if the given species of birds fly
or not, using polymorphism we can do this using a single function.

Example: Polymorphism in Python

 Python3

class Bird:

def intro(self):
print("There are many types of birds.")

def flight(self):
print("Most of the birds can fly but some cannot.")

class sparrow(Bird):

def flight(self):
print("Sparrows can fly.")

class ostrich(Bird):

def flight(self):
print("Ostriches cannot fly.")

obj_bird = Bird()
obj_spr = sparrow()
obj_ost = ostrich()

obj_bird.intro()
obj_bird.flight()

obj_spr.intro()
obj_spr.flight()

obj_ost.intro()
obj_ost.flight()

Output
There are many types of birds.
Most of the birds can fly but some cannot.
There are many types of birds.
Sparrows can fly.
There are many types of birds.
Ostriches cannot fly.
31
Note: For more information, refer to our Polymorphism in Python Tutorial.
Encapsulation
Encapsulation is one of the fundamental concepts in object-oriented programming (OOP). It describes the idea of
wrapping data and the methods that work on data within one unit. This puts restrictions on accessing variables and
methods directly and can prevent the accidental modification of data. To prevent accidental change, an object’s
variable can only be changed by an object’s method. Those types of variables are known as private variables.
A class is an example of encapsulation as it encapsulates all the data that is member functions, variables, etc.

Example: Encapsulation in Python

 Python3

# Python program to
# demonstrate private members

# Creating a Base class


class Base:
def __init__(self):
self.a = "GeeksforGeeks"
self.__c = "GeeksforGeeks"

# Creating a derived class


class Derived(Base):
def __init__(self):

# Calling constructor of
# Base class
Base.__init__(self)
print("Calling private member of base class: ")
print(self.__c)

# Driver code
obj1 = Base()
print(obj1.a)

# Uncommenting print(obj1.c) will


# raise an AttributeError

# Uncommenting obj2 = Derived() will


# also raise an AtrributeError as
# private member of base class
# is called inside derived class

Output
GeeksforGeeks

32
In the above example, we have created the c variable as the private attribute. We cannot even access this attribute
directly and can’t even change its value.
Note: for more information, refer to our Encapsulation in Python Tutorial.
Data Abstraction
It hides the unnecessary code details from the user. Also, when we do not want to give out sensitive parts of our code
implementation and this is where data abstraction came.

4.2 Declaring class and creating objects


Example 1: Creating a class and object with class and instance attributes

 Python3

class Dog:

# class attribute
attr1 = "mammal"

# Instance attribute
def __init__(self, name):
self.name = name

# Driver code
# Object instantiation
Rodger = Dog("Rodger")
Tommy = Dog("Tommy")

# Accessing class attributes


print("Rodger is a {}".format(Rodger.__class__.attr1))
print("Tommy is also a {}".format(Tommy.__class__.attr1))

# Accessing instance attributes


print("My name is {}".format(Rodger.name))
print("My name is {}".format(Tommy.name))

Output
Rodger is a mammal
Tommy is also a mammal
My name is Rodger
My name is Tommy

Example 2: Creating Class and objects with methods

 Python3

class Dog:

# class attribute
attr1 = "mammal"

# Instance attribute
def __init__(self, name):

33
self.name = name

def speak(self):
print("My name is {}".format(self.name))

# Driver code
# Object instantiation
Rodger = Dog("Rodger")
Tommy = Dog("Tommy")

# Accessing class methods


Rodger.speak()
Tommy.speak()

Output
My name is Rodger
My name is Tommy
Note: For more information, refer Python Classes and Objects

4.3 Understanding Inheritance


Inheritance is the capability of one class to derive or inherit the properties from another class. The class that derives
properties is called the derived class or child class and the class from which the properties are being derived is called
the base class or parent class. The benefits of inheritance are:
 It represents real-world relationships well.
 It provides the reusability of a code. We don’t have to write the same code again and again. Also, it allows us
to add more features to a class without modifying it.
 It is transitive in nature, which means that if class B inherits from another class A, then all the subclasses of B
would automatically inherit from class A.
Types of Inheritance –
Single Inheritance:
Single-level inheritance enables a derived class to inherit characteristics from a single-parent class.
Multilevel Inheritance:
Multi-level inheritance enables a derived class to inherit properties from an immediate parent class which in turn
inherits properties from his parent class.
Hierarchical Inheritance:
Hierarchical level inheritance enables more than one derived class to inherit properties from a parent class.
Multiple Inheritance:
Multiple level inheritance enables one derived class to inherit properties from more than one base class.

Example: Inheritance in Python

 Python3

# Python code to demonstrate how parent constructors


# are called.

# parent class
class Person(object):

# __init__ is known as the constructor


def __init__(self, name, idnumber):
self.name = name

34
self.idnumber = idnumber

def display(self):
print(self.name)
print(self.idnumber)

def details(self):
print("My name is {}".format(self.name))
print("IdNumber: {}".format(self.idnumber))

# child class
class Employee(Person):
def __init__(self, name, idnumber, salary, post):
self.salary = salary
self.post = post

# invoking the __init__ of the parent class


Person.__init__(self, name, idnumber)

def details(self):
print("My name is {}".format(self.name))
print("IdNumber: {}".format(self.idnumber))
print("Post: {}".format(self.post))

# creation of an object variable or an instance


a = Employee('Rahul', 886012, 200000, "Intern")

# calling a function of the class Person using


# its instance
a.display()
a.details()

Output
Rahul
886012
My name is Rahul
IdNumber: 886012
Post: Intern
In the above article, we have created two classes i.e. Person (parent class) and Employee (Child Class). The Employee
class inherits from the Person class. We can use the methods of the person class through employee class as seen in the
display function in the above code. A child class can also modify the behavior of the parent class as seen through the
details() method.
Note: For more information, refer to our Inheritance in Python tutorial.

35
5.Developing a GUI with PyQT
5.1 Qt Designer
The PyQt installer comes with a GUI builder tool called Qt Designer. Using its simple drag and drop interface, a GUI
interface can be quickly built without having to write the code. It is however, not an IDE such as Visual Studio. Hence, Qt
Designer does not have the facility to debug and build the application.
Creation of a GUI interface using Qt Designer starts with choosing a top level window for the application.

You can then drag and drop required widgets from the widget box on the left pane. You can also assign value to properties
of widget laid on the form.

36
The designed form is saved as demo.ui. This ui file contains XML representation of widgets and their properties in the
design. This design is translated into Python equivalent by using pyuic4 command line utility. This utility is a wrapper for
uic module. The usage of pyuic4 is as follows −
pyuic4 –x demo.ui –o demo.py
In the above command, -x switch adds a small amount of additional code to the generated XML so that it becomes a self-
executable standalone application.
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Dialog = QtGui.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
The resultant python script is executed to show the following dialog box −

The user can input data in input fields but clicking on Add button will not generate any action as it is not associated with
any function. Reacting to user-generated response is called as event handling.

37
6.Applications

1) Web Applications

We can use Python to develop web applications. It provides libraries to handle internet protocols such as HTML and XML,
JSON, Email processing, request, beautifulSoup, Feedparser, etc. One of Python web-framework named Django is used
on Instagram. Python provides many useful frameworks, and these are given below:

o Django and Pyramid framework(Use for heavy applications)


o Flask and Bottle (Micro-framework)
o Plone and Django CMS (Advance Content management)

2) Desktop GUI Applications

The GUI stands for the Graphical User Interface, which provides a smooth interaction to any application. Python provides
a Tk GUI library to develop a user interface. Some popular GUI libraries are given below.

o Tkinter or Tk
o wxWidgetM
o Kivy (used for writing multitouch applications )
o PyQt or Pyside

3) Console-based Application

Console-based applications run from the command-line or shell. These applications are computer program which are used
commands to execute. This kind of application was more popular in the old generation of computers. Python can develop
this kind of application very effectively. It is famous for having REPL, which means the Read-Eval-Print Loop that makes
it the most suitable language for the command-line applications.

Python provides many free library or module which helps to build the command-line apps. The necessary IO libraries are
used to read and write. It helps to parse argument and create console help text out-of-the-box. There are also advance
libraries that can develop independent console apps.

4) Software Development

Python is useful for the software development process. It works as a support language and can be used to build control and
management, testing, etc.

o SCons is used to build control.


o Buildbot and Apache Gumps are used for automated continuous compilation and testing.
o Round or Trac for bug tracking and project management.

5) Scientific and Numeric

This is the era of Artificial intelligence where the machine can perform the task the same as the human. Python language
is the most suitable language for Artificial intelligence or machine learning. It consists of many scientific and
mathematical libraries, which makes easy to solve complex calculations.

38
Implementing machine learning algorithms require complex mathematical calculation. Python has many libraries for
scientific and numeric such as Numpy, Pandas, Scipy, Scikit-learn, etc. If you have some basic knowledge of Python, you
need to import libraries on the top of the code. Few popular frameworks of machine libraries are given below.

o SciPy
o Scikit-learn
o NumPy
o Pandas
o Matplotlib

6) Business Applications

Business Applications differ from standard applications. E-commerce and ERP are an example of a business application.
This kind of application requires extensively, scalability and readability, and Python provides all these features.

Oddo is an example of the all-in-one Python-based application which offers a range of business applications. Python
provides a Tryton platform which is used to develop the business application.

7) Audio or Video-based Applications

Python is flexible to perform multiple tasks and can be used to create multimedia applications. Some multimedia
applications which are made by using Python are TimPlayer, cplay, etc. The few multimedia libraries are given below.

o Gstreamer
o Pyglet
o QT Phonon

8) 3D CAD Applications

The CAD (Computer-aided design) is used to design engineering related architecture. It is used to develop the 3D
representation of a part of a system. Python can create a 3D CAD application by using the following functionalities.

o Fandango (Popular )
o CAMVOX
o HeeksCNC
o AnyCAD
o RCAM

9) Enterprise Applications

Python can be used to create applications that can be used within an Enterprise or an Organization. Some real-time
applications are OpenERP, Tryton, Picalo, etc.

10) Image Processing Application

Python contains many libraries that are used to work with the image. The image can be manipulated according to our
requirements. Some libraries of image processing are given below.

o OpenCV
o Pillow
39
7.Conclusion
 Python is a computer programming language often used to build websites and software, automate tasks, and conduct
data analysis. Python is a general-purpose language, meaning it can be used to create a variety of different programs
and isn't specialized for any specific problems.This versatility, along with its beginner-friendliness, has made it one of
the most-used programming languages today.

 It has a simple syntax that mimics natural language, so it’s easier to read and understand. This makes it quicker to
build projects, and faster to improve on them.

 It’s versatile. Python can be used for many different tasks, from web development to machine learning.

 It’s beginner friendly, making it popular for entry-level coders.

 It’s open source, which means it’s free to use and distribute, even for commercial purposes.

 Python’s archive of modules and libraries—bundles of code that third-party users have created to expand Python’s
capabilities—is vast and growing.

 Python has a large and active community that contributes to Python’s pool of modules and libraries, and acts as a
helpful resource for other programmers. The vast support community means that if coders run into a stumbling block,
finding a solution is relatively easy; somebody is bound to have encountered the same problem before.

40

You might also like