0% found this document useful (0 votes)
40 views49 pages

Ec210g - Lab Manual

The document outlines a lab manual for a Python programming course. It includes the vision and mission statements of the institute and department. It then lists the 16 practical assignments students will complete, including developing programs that use operators, conditional statements, loops, data structures, functions, modules, OOP concepts, and file I/O. The course outcomes are also listed, which are for students to be able to display messages, use operators, work with data structures, develop functions, design classes, and handle exceptions in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views49 pages

Ec210g - Lab Manual

The document outlines a lab manual for a Python programming course. It includes the vision and mission statements of the institute and department. It then lists the 16 practical assignments students will complete, including developing programs that use operators, conditional statements, loops, data structures, functions, modules, OOP concepts, and file I/O. The course outcomes are also listed, which are for students to be able to display messages, use operators, work with data structures, develop functions, design classes, and handle exceptions in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 49

Govt.

Polytechnic, Nagpur Python Programming

GOVERNMENT POLYTECHNIC, NAGPUR


DEPARTMENT OF ELECTRONICS &
TELECOMMUNICATION

LAB MANUAL
NAME OF COURSE: PYTHON PROGRAMMING
COURSE CODE: EC210G
Govt. Polytechnic, Nagpur Python Programming

Vision of the Institute


To become a Centre of Excellence, providing quality technical
education and training.

Mission of the Institute


4. To frame institutional policies for effective implementation of teaching
learning process.
5. To inculcate values and ethics for life-long learning through curricular,
Co-curricular and extra- curricular activities.
6. To develop facilities and services for academic excellence.
7. To enhance the skills of faculties and staff through industry institute
collaboration.

Vision of the Electronics & Telecommunication Engineering Dept.


To thrive for academic excellence through creation of innovative, ethical,
emotionally intelligent and globally acceptable professionals in the field
of Electronics and Telecommunication Engineering satisfying societal
technological needs.

Mission of the Electronics & Telecommunication Engineering Dept.


M1: To impart high quality electronic and telecommunication engineering
education embedded with professional ethics and Entrepreneur
qualities.
M2: To adopt the best effective instructional methods in order to
maximize knowledge transfer.
M3: To acquire adequate and innovative processes to enhance
understanding of implementation of theoretical concepts in practical
scenarios.
M4: To facilitate the best infrastructure, progressive academic environment
to the students and faculty members, creating an ambience, conducive for
excellence in electronic and telecommunication engineering education.
Govt. Polytechnic, Nagpur Python Programming

The Program Educational Objectives


1. To acquire a fundamental knowledge in Engineering and Science to
improve lives and livelihoods through a successful career in Electronics
and Telecommunication Engineering fields
2. To develop technical competency to provide solution to the problems in
various domain in the field of Electronics and Telecommunication
Engineering.
3. To attain the skills of professional leadership to deliver effectively in a
multi-disciplinary team.
4. To attain professional excellence to produce technocrats who ensure
professional ethical and moral behavior to address social, technical and
business challenges.
5. To engage in lifelong learning and professional development through
self-study continuing education or professional studies in Electronics
and Telecommunication Engineering.
Govt. Polytechnic, Nagpur Python Programming

LIST OF PRACTICALS/LABORATORY EXPERIENCES/ASSIGNMENTS:


Practical’s Specific Learning Outcomes (Psycho- Units Hrs.
motor Domain)
1. Install and configure Python IDE. 1. Introduction 02
and Syntax of
2. Develop and execute simple Python program
Python Program 02
to display message on screen.
3. Develop and execute simple Python program 2. Python
using operators: - operators
 Arithmetic operators and Control flow
02
statements
 Logical operators
 Bitwise operators
4. Develop and execute simple Python program
to demonstrate use of conditional statement: -
 ‘if’ statement 02
 ‘if…... else’ statement
 Nested ‘if’ statement
5. Develop and execute simple Python program
to demonstrate use of looping statement: -
 ‘while’ loop 02
 ‘for’ loop
 Nested loop
6. Develop and execute simple Python program 3. Data structures
to perform following operations on Lists: - in Python
 Create List
 Access List 02
 Update List (Add items, Remove
items)
 Delete List
7. Develop and execute simple Python program
to perform following operations on Tuples: -
 Create Tuple
02
 Access Tuple
 Update Tuple
 Delete Tuple
8. Develop and execute simple Python program
to perform following operations on Sets: -
 Create Set
02
 Access Set elements
 Update Set
 Delete Set
9. Develop and execute simple Python program 02
to perform following operations on
Dictionary: -
 Create Dictionary
 Access Dictionary
Govt. Polytechnic, Nagpur Python Programming

 Update Dictionary
 Delete Dictionary
 Looping through Dictionary
10. Develop & Execute Python program to 4. Python
demonstrate math built-in functions. (Any functions, modules 02
two programs) and packages
11. Develop and execute user defined Python
function for given problem: -
 Function with minimum two 02
arguments.
 Function returning values.
12. Develop and execute Python program to
demonstrate use of: -
 Built-in module (e.g. Keyword, math, 02
number, operator)
 User defined module.
13. Develop and execute Python program to
demonstrate use of: -
 Built-in packages (e.g. NumPy, 02
Panda)
 User defined packages.
14. Develop and execute Python program to 5. Object oriented
demonstrate following operations: - programming in
Python 02
 Method Overlapping
 Method Overriding
15. Develop and execute Python program to
demonstrate following operations: -
02
 Simple Inheritance
 Multiple Inheritance
16. Develop and execute Python program to 6. File I/O
handle user defined exceptions for given handling and
Exception and
02
problems.
handling

Skill Assessment

Total Hrs. 32
Govt. Polytechnic, Nagpur Python Programming

 COURSE OUTCOMES:
After completing this course student will be able to–
1. Display message on screen using Python script on IDE.
2. Develop Python program to demonstrate use of operators.
3. Perform operations on data structure in Python.
4. Develop Python functions for given problem.
5. Design Python classes for given problem.
6. Handle exceptions in Python file management.
Govt. Polytechnic, Nagpur Python Programming

INDEX

SR. NO. COs NAME OF EXPERIMENT PAGE NO.


1 CO1 Install and configure Python IDE.

2 CO1 Develop and execute simple Python


program to display message on screen.

3 CO2 Develop and execute simple Python


program using operators: -
 Arithmetic operators
 Logical operators
 Bitwise operators
4. CO2 Develop and execute simple Python
program to demonstrate use of
conditional statement: -
 ‘if’ statement
 ‘if…... else’ statement
 Nested ‘if’ statement
5. CO2 Develop and execute simple Python
program to demonstrate use of looping
statement: -
 ‘while’ loop
 ‘for’ loop
 Nested loop
6. CO3 Develop and execute simple Python
program to perform following operations
on Lists: -
 Create List
 Access List
 Update List (Add items, Remove
items)
 Delete List
7. CO3 Develop and execute simple Python
program to perform following operations
on Tuples: -
 Create Tuple
 Access Tuple
 Update Tuple
 Delete Tuple
8 CO3 Develop and execute simple Python
program to perform following operations
on Sets: -
 Create Set
 Access Set elements
 Update Set
Govt. Polytechnic, Nagpur Python Programming

 Delete Set
9 CO3 Develop and execute simple Python
program to perform following operations
on Dictionary: -
 Create Dictionary
 Access Dictionary
 Update Dictionary
 Delete Dictionary
 Looping through Dictionary
10 CO4 Develop & Execute Python program to
demonstrate math built-in functions.
(Any two programs)
11 CO4 Develop and execute user defined
Python function for given problem: -
 Function with minimum two
arguments.
 Function returning values.
12 CO4 Develop and execute Python program to
demonstrate use of: -
 Built-in module (e.g. Keyword,
math, number, operator)
 User defined module.
13 CO4 Develop and execute Python program to
demonstrate use of: -
 Built-in packages (e.g. NumPy,
Panda)
 User defined packages.
14 CO5 Develop and execute Python program to
demonstrate following operations: -
 Method Overlapping
 Method Overriding
15 CO5 Develop and execute Python program to
demonstrate following operations: -
 Simple Inheritance
 Multiple Inheritance
16 CO6 Develop and execute Python program to
handle user defined exceptions for given
problems.
17 Python Mini Project
Govt. Polytechnic, Nagpur Python Programming

RUBRICS
Govt. Polytechnic, Nagpur Python Programming

Experiment No. 1

Aim of the experiment:

Install and configure Python IDE.

Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE Python Software

Theory:

Installation of Python:

 Search Python
 Select the version of Python to install

 Download the setup file (installer libraries) of Python Software.


 Once downloading of file is finished, double click on downloaded file to
run installer.
 For installation setup window shows two options: -
 Install now
 Customize Installation
Govt. Polytechnic, Nagpur Python Programming

 If “Install Now” option gets selected it means user will be


an administrator. This option installs Python in user
directory shown in the dialog box under Install Now
option.
 For “Customize installation”, this option allows the user
to select the features to install such as user can select
installation location.
 Install all files.

 Then click on Next option.


 Then Advance option pages appears: - Tick on Install for all users, Add to
environment variables and Precompiled standard library.
Govt. Polytechnic, Nagpur Python Programming

 Then click on install option.


 Successfully installed installer.

 Now close the window.

Result:

In this experiment, we have study how to install a programming interpreter.


Govt. Polytechnic, Nagpur Python Programming

REVIEW QUESTIONS:
1. How to install Python IDE?
2. For installation, which option is selected.
3. Why users click on customize option?
4. State the reason; Python called as interpreter and not compiler?
5. For what purpose Python is required.

RELEVANT COURSE OUTCOMES:

Sr.
No CO Course Outcomes
.
1 CO1 Display message on screen using Python script on IDE.
Govt. Polytechnic, Nagpur Python Programming

Experiment No. 2

Aim of the experiment:

Develop and execute simple Python program to display message on screen.

Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE

Theory:

 For printing simple python program of displaying message on screen


there are some examples:
1. “” or ‘’: - The inverted commas are used defining the sentence.
2. print(‘ ’or “ ”) : - For printing the sentence print command and
sentence is defined inside the bracket using inverted commas.

3. The message can be defined using variable and then variable can be
printed.

 Predefined number- The number is defined in code.


4. For printing number, define the number and then print

 User defined number- The number is defined by the user by using int.
The int, used for integer value in the beginning of code.
5. For printing number, use int (integer value) in the beginning of code.
Govt. Polytechnic, Nagpur Python Programming

Result:

In this experiment, we have study how to print simple python program for
displaying message.

REVIEW QUESTIONS:
1. Which is the main element for printing a sentence?
2. In how many ways the sentence is printed.
3. What do you mean by Pre-defined and User- defined statement?

RELEVANT COURSE OUTCOMES:

Sr.
No CO Course Outcomes
.
2 CO1 Display message on screen using Python script on IDE.
Govt. Polytechnic, Nagpur Python Programming

Experiment No. 3

Aim of the experiment:

Develop and execute simple Python program using operators: -


 Arithmetic operators
 Logical operators
 Bitwise operators

Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE

Theory:

 Arithmetic Operators: - The operator consists of different operations


such as addition, subtraction, multiplication, division, percent,
exponential value and round off value.

Operators Description Examples


+ Adds two values together 5+2=7
- Subtracts smaller number from bigger 5-2=3
number
* Multiples two values 5*2=10
/ Divides a number from the other number 5/2=2.5
% Divides a number from the other number the 5%2=1
left over number (remainder) would be the
answer
** Calculates the exponential value of first 5**2=25
number
// Performs integer division, in which the 5 // 2 = 2
round off the answer is completed. Used
only when the answer is in point value (also
called as floor division)
Govt. Polytechnic, Nagpur Python Programming

 Logical Operator: - The logical operator combines the true or false


value of variables or expressions so that user can determine their resultant
truth-value. User can also use the logical operator to create Boolean
expressions that helps to determine whether to perform tasks.

Operators Description Examples


and Determines whether both operands are true. False and False = False
False and True = False
True and False = False
True and True = True
or Determines when one of two operands is False or False = False
true. False or True = True
True or False = True
True or True = True
not Used for inverting the input value like true not True = False
value to false and false to true. not False = True

 Bitwise Operator: - The bitwise operator interacts with the individual


bits in a number. A bitwise operator interacts with each bit within the
number in a specific way.
When working with a logical bitwise operator, a value of 0 counts as false
and value of 1 counts as true.

Operators Description Examples


& (And) Determines whether both individual 3&2=2
bites within two operators are true and 3 = 0011& (*)
sets the resulting bit to true when they 2 = 0010
are. 0010
| (Or) Determines whether either of the 3|2=3
individual bits within two operators is 3 = 0011 | (+)
true and sets the resulting bit to true 2 = 0010
when one of them is. 0011
^ (Exclusive or) Determines whether just one of the 3^2=1
individual bits within two operators is 3 = 0011 ^
true and sets the resulting bit to true 2 = 0010
when one is. When both bits are true or 0001
both bits are false, the result is false.
~ (One’s Calculates the one’s complement value For positive
complement) of a number. number;
~3 = -2
~2 = -1
For negative
Govt. Polytechnic, Nagpur Python Programming

number;
~ (-3) = 4
~ (-2) = 3

<< (Left shift) Divides a number from the other 5%2=1


number the left over number
(remainder) would be the answer
>> (Right shift) Calculates the exponential value of first 5 ** 2 = 25
number

Result: -In this experiment, we have studied different types of operators.

REVIEW QUESTIONS:
1. State different types of operators.
2. How Arithmetic operator operates.
3. How Logical operator operates.
4. How bitwise operator operates.

RELEVANT COURSE OUTCOMES:

Sr.
No CO Course Outcomes
.
3 CO2 Develop Python program to demonstrate use of operators.
Govt. Polytechnic, Nagpur Python Programming

Experiment No. 4

Aim of the experiment:

Develop and execute simple Python program to demonstrate use of conditional


statement: -
 ‘if’ statement
 ‘if…... else’ statement
 Nested ‘if’ statement

Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE

Theory:

• if Statement: -This statement is the easiest method for making decision


in python.

If some condition is true, python should perform the steps.

Syntax- if:

Statement (s)

• If-else Statement: -This statement is used for choosing one of two


options based on condition.

If something is true, python should perform the steps or else statement is


performed.

Syntax- if:

Statement (s)

else:

Statement (s)
Govt. Polytechnic, Nagpur Python Programming

• If-elif-else Statement: -The extra elif is added to the statement. If one


statement is not considered other statements is considered.

Syntax- if:

Statement (s)

elif:

Statement (s)

else:

Statement (s)

• Nested If Statement: -It is a process of making decision in levels, with


each level is reliant on the decision made at the previous level is called as
nesting.

Developers often use nesting technique to create application that can


make complex decision based on inputs.

Syntax: -if:

if:

Statement (s)

else:

Statement (s)

else:

Statement (s)

Program:

 If statement: -

Code: -
Govt. Polytechnic, Nagpur Python Programming

Output: -

 If-else statement: -
Code: -

Output: -
Govt. Polytechnic, Nagpur Python Programming

 Nested If Statement: -

Code: -

Output: -

Result: -In this experiment, we have studied different types of conditional


statements.

REVIEW QUESTIONS:
1. State different types of conditional statements.
2. How if condition works.
3. State the use of if condition.
4. State the use of if-else condition.
5. State the use of nested if condition.
6. How if-else condition works.
7. How nested if condition operates.
RELEVANT COURSE OUTCOMES:

Sr.
No CO Course Outcomes
.
4 CO2 Develop Python program to demonstrate use of operators.
Govt. Polytechnic, Nagpur Python Programming

Experiment No. 5

Aim of the experiment:

Develop and execute simple Python program to demonstrate use of looping


statement: -
 ‘while’ loop
 ‘for’ loop
 Nested loop

Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE

Theory:

 While Loop: - Is used for the situation where the user is not sure how
much data the application will have to process. This kind of loop is used
when user needs to perform task such as downloading files of unknown
size.
 Syntax: - while expression:
Statement

 For Loop: - This loop begins with for statement. For loop works through
a sequence of type. The sequence may be series of letters in a string or a
specific range of values.
 Syntax: -for iterating _ var in sequence:
Statement
 Nested Loop Statement: - Either for loop or while loop is used. Nesting
the while loop in for loop.
 Syntax: - for iterating _ var in sequence:
Statement

while expression:
Statement
Govt. Polytechnic, Nagpur Python Programming

Program:

 While Loop:

Code: -

Output: -

 For Loop:

Code: -

Output: -
Govt. Polytechnic, Nagpur Python Programming

 Nested Loop:

For loop: -

Code: -

Output: -

While Loop:

Code: -
Govt. Polytechnic, Nagpur Python Programming

Output: -

Result: -In this experiment, we have studied different types of looping


statements.

REVIEW QUESTIONS:
1. State different types of looping statements.
2. How while loop works.
3. State the use of while loop.
4. State the use of for loop.
5. State the use of nested loops.
6. How for loop works.
7. How nested loop operates.

RELEVANT COURSE OUTCOMES:

Sr.
No CO Course Outcomes
.
5 CO2 Develop Python program to demonstrate use of operators.
Govt. Polytechnic, Nagpur Python Programming

Experiment No.6

Aim of the experiment:


Develop and execute simple Python program to perform following operations on
Lists: -
 Create List
 Access List
 Update List (Add items, Remove items)
 Delete List
Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE
Theory:

 Creating List: -The list is a built–in function, created by string and


integer value.

 Accessing List: -after creating list user can, access the information i.e.
stored in list. For accessing the list, we can write print() statement or
single elements in list can also be printed by defining specific location of
that element. The user can also access range of elements in defined list
using a[first location: last location]
Govt. Polytechnic, Nagpur Python Programming

 Update List: - The user can perform different functions of list:

Sr. List method / function Description


No.
1 .append() Adds a new entry to the end of list.
2 .clear() Removes all entries from a list.
3 .copy() Creates a copy of the current list and place it
in a new list.
4 .extend() Add items from an existing list (one list) and
into the current list-working (list).
5 .insert() Adds a new entry to the position specified in
the list.
6 .reverse() Used for counting the list from reverse order
i.e. from descending order.
7 .sort() Used for sorting or arranging the order of list.
8 .pop() Used for removing an entry from the end of
the list or position specified.
9 .remove() Removes an entry from the specified position
in the list.
10 len() Used for defining the length of list.
Govt. Polytechnic, Nagpur Python Programming

 Delete List: -The delete list consists of different functions such as pop(),
remove() and clear(), with the help of these functions user can delete the
list.

Result: -In this experiment, we have studied the different functions that can be
performed by list.

REVIEW QUESTIONS:
1. State different functions of executing Python code by list.
2. How append() function works.
3. State the advantages of using list.
4. State different operations used for adding an element to the list.
5. State different operations used for removing element from the list.
6. How extend() function operates in the list.
7. State different methods for accessing a list.
8. To access a particular number, the user enters a number or a specific
location, state true or false.
9. Compare the list functions pop() and remove().

RELEVANT COURSE OUTCOMES:

Sr.
No CO Course Outcomes
.
6 CO3 Perform operations on data structure in Python.
Govt. Polytechnic, Nagpur Python Programming

Experiment No.7

Aim of the experiment:

Develop and execute simple Python program to perform following operations


on Tuple: -
 Create Tuple
 Access Tuple
 Update Tuple (Add items, Remove items)
 Delete Tuple
Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE

Theory:

 Creating Tuple: - The tuple is a built–in function, for creating tuple


string as well as the integer values are used.

 Accessing Tuple: -After creating tuple user can, access the information
i.e. stored in tuple. For accessing the tuple, we can write print() statement
or single elements in tuple can be printed by defining specific location of
that element. The user can also access range of elements in defined list
using a[first location: last location]
Govt. Polytechnic, Nagpur Python Programming

 Update Tuple: - The user can perform different functions of tuples:

Sr. List method / function Description


No.
1 cmp() Compares elements of more than one defined
tuple.
2 max() Returns item from the tuple with max value.
3 min() Returns item from the tuple with min value.
4 tuple() Converts given input data into tuple.
5 len() Used for defining the length of tuple.
6 Arithmetic operator Used for adding as well as multiplying the
(+,*) elements in the tuple.
7 del() Used for deleting the defined tuple.

 Delete Tuple: - The delete tuple consists of del() function, with the help
of this function user can delete the tuple.
Govt. Polytechnic, Nagpur Python Programming

Result: -In this experiment, we have studied the different functions that can be
performed by tuples.

REVIEW QUESTIONS:
1. State different functions of executing Python code by tuple.
2. State, how tuple() function works.
3. State the advantages of using tuple.
4. State different operations used for adding an element to the tuple.
5. State, how del() function works.
6. State different methods for accessing a tuple.
7. To access a particular number, the user enters a number or a specific
location, state true or false.

RELEVANT COURSE OUTCOMES:

Sr.
No CO Course Outcomes
.
7 CO3 Perform operations on data structure in Python.
Govt. Polytechnic, Nagpur Python Programming

Experiment No.8

Aim of the experiment:

Develop and execute simple Python program to perform following operations


on Sets: -
 Create Set
 Access Set
 Update Set (Add items, Remove items)
 Delete Set
Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE
Theory:

 Create Set: - The set is a built–in function, for creating set integer values
are used. The sets are created by using set([]) or by using {} brackets.

 Accessing Set: - For accessing sets print() statement is used. The


individual elements cannot be accessed. For accessing n number of
elements looping is used.

 Update Set: - The user can perform different functions of sets:

Sr. List method / function Description


No.
1 .add() Used for adding an element to a set.
2 .remove() Used for removing an element from a set.
3 .union() Used for combining more than one set.
4 .intersection() Used for finding common elements for more
than one set.
Govt. Polytechnic, Nagpur Python Programming

5 .difference() Used for finding uncommon elements for


more than one set.
6 .issubset() When all the elements of a set are same with
other set then output would be true and when
elements of a set is different the output would
False.
7 .issuperset() When single element of a set is same with
other set then output would be true and when
all the elements are different then output
would be False.
8 .isdisjoint() For the elements in defined set are same the
output would be false and for the elements in
defined set are different the output would be
True.
9 .copy() Creates a copy of the current set and place it in
a new set.
10 .clear() Removes all entries from a set.
11 set() Converts given input data into set.
12 del() Used for deleting the set.
13 len() Used for defining the length of set.

 Deleting Set: - The delete set consists of del() and .clear() functions,
with the help of this function user can delete the set.

Result: -In this experiment, we have studied the different functions that can be
performed by set.
Govt. Polytechnic, Nagpur Python Programming

REVIEW QUESTIONS:
1. State different functions of executing Python code by using set.
2. State, how set() function works.
3. State the advantages of using set.
4. State different operations used for adding an element to the set.
5. State, how del() function works.
6. State different methods for accessing a set.
7. State, how the numbers get added and removed in the set.
8. State the use of .union() and .intersection() in the set.

RELEVANT COURSE OUTCOMES:

Sr.
No CO Course Outcomes
.
8 CO3 Perform operations on data structure in Python.
Govt. Polytechnic, Nagpur Python Programming

Experiment No.9

Aim of the experiment:

Develop and execute simple Python program to perform following operations


on Dictionary: -
 Create Dictionary
 Access Dictionary
 Update Dictionary
 Delete Dictionary
 Looping through Dictionary

Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE

Theory:

 Create Dictionary: - The dictionary is a built–in function, for creating


dictionary integer as well as string, values are used. The dictionary is
formed by using {} brackets.

 Accessing Dictionary: -After creating dictionary user can, access the


information i.e. stored in dictionary. For accessing the dictionary, we can
write print() statement or single elements in dictionary can be printed by
using defining specific name of that element in [] bracket.
Govt. Polytechnic, Nagpur Python Programming

 Update Dictionary: - The user can perform different functions of


dictionary:

Sr. List method / function Description


No.
1 .keys() Used for printing only keywords of defined
dictionary.
2 .update() Used for updating defined dictionary.
3 .copy() Creates a copy of the current dictionary and
place it in a new dictionary.
4 .clear() Removes all entries from a dictionary.
5 del() Used for deleting the dictionary.
6 len() Used for defining the length of dictionary.
7 .fromkeys() Used for assigning none to the particular
defined element.

 Delete Dictionary: -The delete dictionary consists of del() and .clear()


functions, with the help of this function user can delete the set.
Govt. Polytechnic, Nagpur Python Programming

Result: -In this experiment, we have studied the different functions that can be
performed by dictionary.

REVIEW QUESTIONS:
1. State different functions of executing Python code by using dictionary.
2. State, how dictionary {} bracket works.
3. State the advantages of using dictionary.
4. State different operations used for adding an element to the dictionary.
5. State, how del() function works.
6. State different methods for accessing a dictionary.
7. State, how the numbers get updated in the dictionary.
8. State the use of .keys() in dictionary.

RELEVANT COURSE OUTCOMES:

Sr.
No CO Course Outcomes
.
9 CO3 Perform operations on data structure in Python.
Govt. Polytechnic, Nagpur Python Programming

Experiment No.10

Aim of the experiment:

Develop & Execute Python program to demonstrate math built-in functions.


(Any two programs)

Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE

Theory:

 Math built-in function: The user can perform different functions by


using:

Sr. List method / function Description


No.
1 .pi() Used for providing the value of pi.
2 .sqrt() Used for printing square root value of a
particular element.
3 .radians() Used for printing radians value of a particular
Govt. Polytechnic, Nagpur Python Programming

element.
4 .degrees() Used for printing degrees value of a particular
element.
5 .exp() Used to provide exponential value of a
particular element.
6 .sin(),.cos(),.tan() Trigonometry functions can be performed by
math in built function.
7 .log() Performs logarithmic functions.
8 .floor(), .ceil() Used for providing round off value i.e.
incremented value or decremented value.

Result: -In this experiment, we have studied the different functions that can be
performed by using math function.

REVIEW QUESTIONS:
1. State different functions for executing Python code by using math built-in
function.
2. State how does math function operates.
3. State the advantages of using math function.
Govt. Polytechnic, Nagpur Python Programming

4. State different operations performed by math function.


5. State difference in .floor() and .ceil() functions.
6. State different trigonometry functions performed by math function.
7. State the use of .degrees() and .exp() functions.
RELEVANT COURSE OUTCOMES:

Sr.
No CO Course Outcomes
.
10 CO4 Develop Python functions for given problem.

Experiment No.11

Aim of the experiment:

Develop and execute user defined Python function for given problem: -
 Function with minimum two arguments.
 Function returning values.

Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE

Theory:

 Function with minimum two arguments: The function with two


arguments means two variables or numbers are defined inside the ()
bracket.
Govt. Polytechnic, Nagpur Python Programming

 Function returning values: The return statement is used for returning


operations that are defined inside the function.

Result: -In this experiment, we have studied the use of user defined python
function.

REVIEW QUESTIONS:
1. State the use of user defined python function.
2. State how python functions defined.
3. State the advantages of using python function.
4. State different operations performed by python function.
5. State meaning of return function.
6. State how arguments are defined and also functions are called.
7. State the comparison between Global variables and Local variables.
Govt. Polytechnic, Nagpur Python Programming

RELEVANT COURSE OUTCOMES:

Sr.
No CO Course Outcomes
.
11 CO4 Develop Python functions for given problem.

Experiment No.12

Aim of the experiment:

Develop and execute Python program to demonstrate use of -


 Built-in module (e.g. Keyword, math, number, operator).
 User defined module.
Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE
Theory:

 Built-in Module (e.g. Keyword, math, number, operator):

Sr. List Keywords/ Types of Keywords


No. functions
1 Value Keyword True, false, None
2 Operator Keyword and, or, not, in not, is, is not,+, -, /, //,
*,>>,<<,&,|,~, ^
3 Control flow keyword if, else, nested if
4 Iteration while, for, nested while, nested for, break,
Keyword(looping pass, continue, else
keyword)
5 Returning keyword Return
6 Structure Keyword def, class
7 Import Keywords Import
8 Number Keyword int, float, floor
Govt. Polytechnic, Nagpur Python Programming

9 math function .pi(), .sqrt(), .radians(), .degrees(), .exp(),


.sin(), .cos(), .tan(), .log(), .floor(), .ceil()

 User defined Module: The user-defined modules are not only but
defined functions.

Result: -In this experiment, we have studied built-in module.


Govt. Polytechnic, Nagpur Python Programming

REVIEW QUESTIONS:
1. State the use of Built-in module.
2. State the uses of different in-built keywords.
3. State the advantages of using built-in module and user-defined modules.
4. State different operations performed by built-in module.
5. User defined modules are called as user defined functions, state true or false.
6. State how arguments defined in user defined modules.
RELEVANT COURSE OUTCOMES:

Sr.
No CO Course Outcomes
.
12 CO4 Develop Python functions for given problem.

Experiment No.13

Aim of the experiment:

Develop and execute Python program to demonstrate use of: -


 Built-in packages (e.g. NumPy, Panda)
 User defined packages.

Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE

Theory:

 Built-in packages (e.g. NumPy, Panda): Built-in packages are already


defined package in python. By importing packages, different functions
and operations are performed. After importing package, the user always,
write “pip install package-name” for activating on command prompt.
Govt. Polytechnic, Nagpur Python Programming

 User defined packages: User defined packages defined by user. Creating


small function files and calling these files with name (import) known as
user-defined modules.
 As many small function files created and these files called in new file
where python performs different operations.
Govt. Polytechnic, Nagpur Python Programming

Experiment No.14

Aim of the experiment:

Develop and execute Python program to demonstrate following operations: -


 Method Overlapping
 Method Overriding

Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE

Theory:

 Method Overloading: Creates more than one version of a function,


which results in different behavior.
The main task of function would be the same, but inputs are different and
potentially the output would be different.
The function overloading is required for providing flexibility so that
functions can work with applications in various ways.
Govt. Polytechnic, Nagpur Python Programming

 Method Overriding: For overriding, python automatically uses


appropriate sub-class implementation of method instead of main class
implementation.
 The function overriding is fundamental concept of object oriented
programming and used extensively in many python libraries and
framework.
Govt. Polytechnic, Nagpur Python Programming

Result: -In this experiment, we have studied overloading and overriding in


function as well in class.

REVIEW QUESTIONS:
1. State the use of classes.
2. State the uses of method overloading and method overriding in python.
3. State the use of function overloading.
4. State the use of operator overloading.
5. Comparison between function and operator overloading.
6. Do operation and functions are same, state true or false.
RELEVANT COURSE OUTCOMES:

Sr.
No CO Course Outcomes
.
1 CO5 Design Python Classes for given problem..

Experiment No.15

Aim of the experiment:

Develop and execute Python program to demonstrate following operations: -


 Simple Inheritance
 Multiple Inheritance

Apparatus:

Sr. No. Name of Specification Quantity


Component and
Software
1 Computer or Laptop 1
2 Python IDE, Python Python Software
IDLE

Theory:

 Simple Inheritance:

You might also like