Advanced Python Programming Lab Manual 2025
Advanced Python Programming Lab Manual 2025
Laboratory Manual
DTE’s Vision:
To facilitate quality technical and professional education having relevance for both
industry and society, with moral and ethical values, giving equal opportunity and access,
aiming to prepare globally competent technocrats.
DTE’s Mission:
• Quality technical and professional education with continuous improvement of all the
resources and personnel
• To promote conducive ecosystem for Academic, Industry, Research, Innovations
and Startups
• To provide affordable quality professional education with moral values, equal
opportunities, accessibility and accountability
• To allocate competent and dedicated human resources and infrastructure to the
institutions for providing world-class professional education to become a Global
Leader (“Vishwa Guru”)
Institute’s Vision:
To develop technically proficient and ethically sound diploma engineers contributing
to industry and society needs.
Institute’s Mission:
• To impart quality technical education.
• To shape students towards sensitizing in ethical values and contributing to nature.
• To familiarize students with the world of work.
Department’s Vision:
To develop technically proficient and ethically sound diploma IT engineers to serve the
industry and society.
Department’s Mission:
• To impart IT engineering education through an effective teaching-learning process.
• Making our students contributory and believing in ethical values.
• Making students aware and practice current technology in industry.
Page 2 of 62
Advanced Python Programming (DI02016011)
Certificate
Place:…………………..
Date: …………………..
Page 3 of 62
Advanced Python Programming (DI02016011)
Preface
The primary aim of any laboratory/Practical/field work is enhancement of required skills as well as
creative ability amongst students to solve real time problems by developing relevant competencies in
psychomotor domain. Keeping in view, GTU has designed competency focused outcome-based
curriculum NEP (2020) for Diploma engineering programmes. In this more time is allotted to practical
work than theory. It shows importance of enhancement of skills amongst students and it pays attention
to utilize every second of time allotted for practical amongst Students, Instructors and Lecturers to
achieve relevant outcomes by performing rather than writing practice in study type. It is essential for
effective implementation of NEP curriculum. Every practical has been keenly designed to serve as a tool
to develop & enhance relevant industry needed competency in each and every student. These
psychomotor skills are very difficult to develop through traditional chalk and board content delivery
method in the classroom. Accordingly, this lab manual has been designed to focus on the industry
defined relevant outcomes, rather than old practice of conducting practical to prove concept and theory.
By using this lab manual, students can read procedure one day in advance to actual performance day of
practical experiment which generates interest and also, they can have idea of judgement of magnitude
prior to performance. This in turn enhances predetermined outcomes amongst students. Each and every
Experiment /Practical in this manual begins by competency, industry relevant skills, course outcomes
as well as practical outcomes which serve as a key role for doing the practical. The students will also
have a clear idea of safety and necessary precautions to be taken while performing experiment.
This manual also provides guidelines to lecturers to facilitate student-centred lab activities for each
practical/experiment by arranging and managing necessary resources in order that the students follow
the procedures with required safety and necessary precautions to achieve outcomes. It also gives an idea
that how students will be assessed by providing Rubrics.
Python is a modern language useful for writing compact codes specifically for programming in
the area of Server-side Web development, Data Analytics, AI, and scientific computing as well as
production tools and game programming. This course deals with some advanced features of the ‘Python’
language. The programming skills thus acquired can be used for developing programs with advanced
level programming features which in turn will be helping in developing practical applications for the
scientific, research and business purposes. At the end of the course, the student will be able to develop
programs with adequate advanced concepts using python language.
Although we try our level best to design this lab manual, but always there are chances of improvement
Page 4 of 62
Advanced Python Programming (DI02016011)
Page 5 of 62
Advanced Python Programming (DI02016011)
Page 6 of 62
Advanced Python Programming (DI02016011)
Page 7 of 62
Advanced Python Programming (DI02016011)
The following industry relevant skills are expected to be developed in the students by
performance of experiments of this course.
1. Organize the work in the group and make record of all observations.
2. Students shall develop maintenance skill as expected by industries.
3. Student shall attempt to develop related hand-on skills and build confidence.
4. Student shall develop the habits of evolving more ideas, innovations, skills etc.
5. Student shall refer technical magazines and data books.
6. Student should develop habit to submit the practical on date and time.
7. Student should well prepare while submitting write-up of exercise.
Page 8 of 62
Advanced Python Programming (DI02016011)
Practical Rubrics
Page 9 of 62
Advanced Python Programming (DI02016011)
Page 10 of 62
Advanced Python Programming (DI02016011)
Page 11 of 62
Advanced Python Programming (DI02016011)
Practical No.1: Write a program to demonstrate the set functions and operations.
A. Objective:
Apply set functions and operations to solve particular problem.
B. Expected Program Outcomes (POs)
1. Basic and Discipline specific knowledge: Be able to apply engineering
knowledge of computing appropriate to the problem
2. Design/ development of solutions: Be able to design, implement, and evaluate
a computer based system, process, component, or program to meet the desired
needs
3. Engineering Tools, Experimentation and Testing: Be able to use and apply
current technical concepts and best practices in information technologies
C. Expected Skills to be developed based on competency:
This practical is expected to develop the following skills for the
industry-identified competency:
1. Problem solving skill using set functions and operations in advanced python.
Page 12 of 62
Advanced Python Programming (DI02016011)
Code
Output
Page 13 of 62
Advanced Python Programming (DI02016011)
Practical No.2: i) Write a program to input n numbers from the user and store these
numbers in a tuple. Print the maximum and minimum number from this tuple.
ii) Create a user-defined function that prints a tuple whose values are the cube of a number
between 1 and n (both included), Where n is an integer number and passed as an argument.
A. Objective:
Apply tuple methods and operations to solve particular problem.
B. Expected Program Outcomes (POs)
1. Basic and Discipline specific knowledge: Be able to apply engineering
knowledge of computing appropriate to the problem
2. Design/ development of solutions: Be able to design, implement, and evaluate
a computer based system, process, component, or program to meet the desired
needs
3. Engineering Tools, Experimentation and Testing: Be able to use and apply
current technical concepts and best practices in information technologies
C. Expected Skills to be developed based on competency:
This practical is expected to develop the following skills for the
industry-identified competency:
1. Problem solving skill using tuple methods and operations in advanced python.
Page 14 of 62
Advanced Python Programming (DI02016011)
i) Write a program to input n numbers from the user and store these numbers in a tuple. Print the
maximum and minimum number from this tuple.
code
output:
Page 15 of 62
Advanced Python Programming (DI02016011)
ii) Create a user-defined function that prints a tuple whose values are the cube of a number
between 1 and n (both included), Where n is an integer number and passed as an argument.
code
output:
Page 16 of 62
Advanced Python Programming (DI02016011)
Practical No.3:
i) Write a program to count the number of times a character appears in a given string
using a dictionary
ii) Write a user-defined function to convert a number entered by the user into its
corresponding number in words. For example, if the input is 789 then the output should
be ' Seven Eight Nine’.
A. Objective:
Apply dictionary methods and operations to solve particular problems.
B. Expected Program Outcomes (POs)
1. Basic and Discipline specific knowledge: Be able to apply engineering
knowledge of computing appropriate to the problem
2. Design/ development of solutions: Be able to design, implement, and evaluate
a computer based system, process, component, or program to meet the
desired needs
3. Engineering Tools, Experimentation and Testing: Be able to use and apply
current technical concepts and best practices in information technologies
Page 17 of 62
Advanced Python Programming (DI02016011)
i) Write a program to count the number of times a character appears in a given string using a
dictionary
code
output:
Page 18 of 62
Advanced Python Programming (DI02016011)
ii) Write a user-defined function to convert a number entered by the user into its corresponding
number in words. For example, if the input is 789 then the output should be ' Seven Eight Nine
code
output:
Page 19 of 62
Advanced Python Programming (DI02016011)
Practical No.4: Write a program to define a module to find the area and circumference of a
circle.
a) Import the module to another program.
b) Import a specific function from a module to another program.
A. Objective:
Define a module to find the area and circumference of a circle.
B. Expected Program Outcomes (POs)
1. Basic and Discipline specific knowledge: Be able to apply engineering
knowledge of computing appropriate to the problem
2. Design/ development of solutions: Be able to design, implement, and evaluate a
computer based system, process, component, or program to meet the desired
needs
3. Engineering Tools, Experimentation and Testing: Be able to use and apply
current technical concepts and best practices in information technologies
C. Expected Skills to be developed based on competency:
This practical is expected to develop the following skills for the industry-
identified competency:
1. Problem solving skill using module in advanced python.
Page 20 of 62
Advanced Python Programming (DI02016011)
#circle.py
code
output:
Page 21 of 62
Advanced Python Programming (DI02016011)
#main.py
code
output:
Page 22 of 62
Advanced Python Programming (DI02016011)
#circle.py
code
output:
Page 23 of 62
Advanced Python Programming (DI02016011)
#main.py
code
output:
Page 24 of 62
Advanced Python Programming (DI02016011)
Practical No.5: Create a package named DemoPackage which contains two modules
named mathematics and greets. The mathematics module contains sum, average, power
functions, and the greets module contains the sayHello function.
i) Import the module from a package to another program
ii) Import a specific function from a module.
A. Objective:
Apply package and module to solve particular problem.
B. Expected Program Outcomes (POs)
1. Basic and Discipline specific knowledge: Be able to apply engineering
knowledge of computing appropriate to the problem
2. Design/ development of solutions: Be able to design, implement, and evaluate a
computer based system, process, component, or program to meet the desired needs
3. Engineering Tools, Experimentation and Testing: Be able to use and apply
current technical concepts and best practices in information technologies
C. Expected Skills to be developed based on competency:
This practical is expected to develop the following skills for the industry-
identified competency:
1. Problem solving skill using package in advanced python.
Page 25 of 62
Advanced Python Programming (DI02016011)
#DemoPackage/greets.py
code
output:
Page 26 of 62
Advanced Python Programming (DI02016011)
#DemoPackagae/maths.py
code
output:
Page 27 of 62
Advanced Python Programming (DI02016011)
main.py
code
output:
Page 28 of 62
Advanced Python Programming (DI02016011)
#DemoPackage/greets.py
code
output:
Page 29 of 62
Advanced Python Programming (DI02016011)
#DemoPackagae/maths.py
code
output:
Page 30 of 62
Advanced Python Programming (DI02016011)
main.py
code
output:
Page 31 of 62
Advanced Python Programming (DI02016011)
Practical No.6 Install urllib3 package using PIP. Send HTTP requests to any URL and
print status for the same.
A. Objective:
Install urllib3 package using PIP. Send HTTP requests to any URL and print
status for the same.
B. Expected Program Outcomes (POs)
1. Basic and Discipline specific knowledge: Be able to apply engineering
knowledge of computing appropriate to the problem
2. Design/ development of solutions: Be able to design, implement, and evaluate a
computer based system, process, component, or program to meet the desired
needs
3. Engineering Tools, Experimentation and Testing: Be able to use and apply
current technical concepts and best practices in information technologies
C. Expected Skills to be developed based on competency:
This practical is expected to develop the following skills for the industry-
identified competency:
1. Skill to Install urllib3 package using PIP. Send HTTP requests to any URL and print
status for the same.
Page 32 of 62
Advanced Python Programming (DI02016011)
Install urllib3 package using PIP. Send HTTP requests to any URL and print status for the
same.
code
output:
Page 33 of 62
Advanced Python Programming (DI02016011)
Practical No.7 Write a program to catch on DivideByZero Exception with finally clause.
Page 34 of 62
Advanced Python Programming (DI02016011)
code
output:
Page 35 of 62
Advanced Python Programming (DI02016011)
Practical No.8 Write a user-defined exception that could be raised when the text entered
by a user consists of less than 10 characters.
A. Objective:
Write a user-defined exception that could be raised when the text entered by a user
consists of less than 10 characters.
Page 36 of 62
Advanced Python Programming (DI02016011)
Write a user-defined exception that could be raised when the text entered by a user consists of
less than 10 characters.
code
output:
Page 37 of 62
Advanced Python Programming (DI02016011)
A. Objective:
Page 38 of 62
Advanced Python Programming (DI02016011)
code
output:
Page 39 of 62
Advanced Python Programming (DI02016011)
Practical No.10
i) Write a program to read the content of a file line by line and write it to another file except for
the lines containing "a" letter in it.
ii) Write a program that inputs a text file. The program should print all of the unique words in
the file in alphabetical order.
A. Objective:
i) Write a program to read the content of a file line by line and write it to another
file except for the lines containing "a" letter in it.
ii) Write a program that inputs a text file. The program should print all of the unique
words in the file in alphabetical order.
B. Expected Program Outcomes (POs)
1. Basic and Discipline specific knowledge: Be able to apply engineering
knowledge of computing appropriate to the problem
2. Problem Analysis: Identify and analyse well-defined engineering problems using
codified standard methods.
3. Design/ development of solutions: Be able to design, implement, and evaluate a
computer based system, process, component, or program to meet the desired
needs
4. Engineering Tools, Experimentation and Testing: Be able to use and apply
current technical concepts and best practices in information technologies
5. Project Management: Use engineering management principles individually, as a
team member or a leader to manage projects
6. Life-long learning solution: Ability to analyse individual needs and engage in
updating in the context of technological changes.
C. Expected Skills to be developed based on competency:
This practical is expected to develop the following skills for the industry identified
competency:
1. Problem solving skill using file input/output operations in advanced python.
D. Expected Course Outcomes(COs)
CO4: Develop python programs using file input/output operations.
E. Practical Outcome(PRO)
Write a program to read the content of file line by line and write it to another file except for
the lines containing "a" letter in it.
F. Expected Affective domain Outcome(ADOs)
1. Handle computer systems carefully with safety and necessary precaution.
2. Turn off systems after completion of practical lab to save power.
Page 40 of 62
Advanced Python Programming (DI02016011)
i) Write a program to read the content of a file line by line and write it to another file except
for the lines containing "a" letter in it
code
output:
Page 41 of 62
Advanced Python Programming (DI02016011)
ii) Write a program that inputs a text file. The program should print all of the unique words in
the file in alphabetical order.
code
output:
Page 42 of 62
Advanced Python Programming (DI02016011)
Practical No.11 Write a program to create a binary file to store Rollno and Name,
Search any Rollno and display name if Rollno found otherwise “Rollno not found”.
A. Objective:
The objective of practical is to work with binary file and use pickle module to solve
problem.
B. Expected Program Outcomes (POs)
1. Basic and Discipline specific knowledge: Be able to apply engineering
knowledge of computing appropriate to the problem
2. Problem Analysis: Identify and analyse well-defined engineering problems using
codified standard methods.
3. Design/ development of solutions: Be able to design, implement, and evaluate a
computer based system, process, component, or program to meet the desired
needs
4. Engineering Tools, Experimentation and Testing: Be able to use and apply
current technical concepts and best practices in information technologies
5. Project Management: Use engineering management principles individually, as a
team member or a leader to manage projects
6. Life-long learning solution: Ability to analyse individual needs and engage in
updating in the context of technological changes.
C. Expected Skills to be developed based on competency:
This practical is expected to develop the following skills for the industry-identified
competency:
1. Problem solving skill using file input/output operations in advanced python.
Write a program to create a binary file to store Rollno and Name, Search any Rollno and
display name if Rollno found otherwise “Rollno not found”.
F. Expected Affective domain Outcome(ADOs)
1. Handle computer systems carefully with safety and necessary precaution.
2. Turn off systems after completion of practical lab to save power.
Page 43 of 62
Advanced Python Programming (DI02016011)
Write a program to create a binary file to store Rollno and Name, Search any Rollno and display
name if Rollno found otherwise “Rollno not found”.
code
Page 44 of 62
Advanced Python Programming (DI02016011)
output:
Page 45 of 62
Advanced Python Programming (DI02016011)
Practical No.12 Write a program to demonstrate the file and file I/O operations.
A. Objective:
The objective of practical is to apply file I/O Concept.
B. Expected Program Outcomes (POs)
1. Basic and Discipline specific knowledge: Be able to apply engineering
knowledge of computing appropriate to the problem
2. Problem Analysis: Identify and analyse well-defined engineering problems using
codified standard methods.
3. Design/ development of solutions: Be able to design, implement, and evaluate a
computer based system, process, component, or program to meet the desired
needs
4. Engineering Tools, Experimentation and Testing: Be able to use and apply
current technical concepts and best practices in information technologies
5. Project Management: Use engineering management principles individually, as a
team member or a leader to manage projects
6. Life-long learning solution: Ability to analyse individual needs and engage in
updating in the context of technological changes.
C. Expected Skills to be developed based on competency:
This practical is expected to develop the following skills for the industry-identified
competency:
1. Problem solving skill using file input/output operations in advanced python.
D. Expected Course Outcomes(COs)
CO4: Develop python programs using file input/output operations.
E. Practical Outcome(PRO)
Write a program to demonstrate the file and file I/O operations.
F. Expected Affective domain Outcome(ADOs)
1. Handle computer systems carefully with safety and necessary precaution.
2. Turn off systems after completion of practical lab to save power
Page 46 of 62
Advanced Python Programming (DI02016011)
code
Page 47 of 62
Advanced Python Programming (DI02016011)
output
Page 48 of 62
Advanced Python Programming (DI02016011)
Practical No.13
i) Draw square, rectangle, and circle using Turtle.
ii) Draw color-filled shapes (square, rectangle, and circle) using Turtle.
A. Objective:
The objective of practical is draw to square, rectangle, and circle using python
turtle module.
B. Expected Program Outcomes (POs)
1. Basic and Discipline specific knowledge: Be able to apply engineering
knowledge of computing appropriate to the problem
2. Problem Analysis: Identify and analyse well-defined engineering problems using
codified standard methods.
3. Design/ development of solutions: Be able to design, implement, and evaluate a
computer based system, process, component, or program to meet the desired needs
4. Engineering Tools, Experimentation and Testing: Be able to use and apply
current technical concepts and best practices in information technologies
5. Project Management: Use engineering management principles individually, as a
team member or a leader to manage projects
6. Life-long learning solution: Ability to analyse individual needs and engage in
updating in the context of technological changes.
C. Expected Skills to be developed based on competency:
This practical is expected to develop the following skills for the industry-identified
competency:
1. Problem solving skill using python turtle module to draw graphics in advanced python.
Page 49 of 62
Advanced Python Programming (DI02016011)
Page 50 of 62
Advanced Python Programming (DI02016011)
output
Page 51 of 62
Advanced Python Programming (DI02016011)
Page 52 of 62
Advanced Python Programming (DI02016011)
output
Page 53 of 62
Advanced Python Programming (DI02016011)
Practical No.14 Draw a smiling face emoji and rainbow using Turtle.
A. Objective:
The objective of practical is to draw a smiling face emoji and rainbow using Turtle.
B. Expected Program Outcomes (POs)
1. Basic and Discipline specific knowledge: Be able to apply engineering
knowledge of computing appropriate to the problem
2. Problem Analysis: Identify and analyse well-defined engineering problems using
codified standard methods.
3. Design/ development of solutions: Be able to design, implement, and evaluate a
computer based system, process, component, or program to meet the desired
needs
4. Engineering Tools, Experimentation and Testing: Be able to use and apply
current technical concepts and best practices in information technologies
5. Project Management: Use engineering management principles individually, as a
team member or a leader to manage projects
6. Life-long learning solution: Ability to analyse individual needs and engage in
updating in the context of technological changes.
C. Expected Skills to be developed based on competency:
This practical is expected to develop the following skills for the industry-identified
competency:
1. Problem solving skill using python turtle module to draw graphics in advanced
python.
Page 54 of 62
Advanced Python Programming (DI02016011)
code
Page 55 of 62
Advanced Python Programming (DI02016011)
Page 56 of 62
Advanced Python Programming (DI02016011)
output
Page 57 of 62
Advanced Python Programming (DI02016011)
Practical No.15 Draw an Indian Flag and an Olympic Symbol using Turtle.
A. Objective:
The objective of practical is to draw an Indian Flag and an Olympic Symbol using Turtle.
B. Expected Program Outcomes (POs)
1. Basic and Discipline specific knowledge: Be able to apply engineering
knowledge of computing appropriate to the problem
2. Problem Analysis: Identify and analyse well-defined engineering problems using
codified standard methods.
3. Design/ development of solutions: Be able to design, implement, and evaluate a
computer based system, process, component, or program to meet the desired
needs
4. Engineering Tools, Experimentation and Testing: Be able to use and apply
current technical concepts and best practices in information technologies
5. Project Management: Use engineering management principles individually, as a
team member or a leader to manage projects
6. Life-long learning solution: Ability to analyse individual needs and engage in
updating in the context of technological changes.
C. Expected Skills to be developed based on competency:
This practical is expected to develop the following skills for the industry-identified
competency:
1. Problem solving skill using python turtle module to draw graphics in advanced
python.
Page 58 of 62
Advanced Python Programming (DI02016011)
code
Page 59 of 62
Advanced Python Programming (DI02016011)
Page 60 of 62
Advanced Python Programming (DI02016011)
Page 61 of 62
Advanced Python Programming (DI02016011)
output
Page 62 of 62