0% found this document useful (0 votes)
17 views107 pages

DI02032011 - Python Programming

This document is a laboratory manual for a Python Programming course (DI02032011) at Government Polytechnic, Ahmedabad, aimed at diploma students in Information and Communication Technology for the academic term 2025-26. It outlines the vision and mission of the Directorate of Technical Education and the institute, details the course structure, practical outcomes, and assessment methods, and emphasizes the importance of hands-on experience in developing relevant skills. The manual includes a variety of practical exercises designed to enhance students' programming competencies and prepare them for industry demands.

Uploaded by

meera
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views107 pages

DI02032011 - Python Programming

This document is a laboratory manual for a Python Programming course (DI02032011) at Government Polytechnic, Ahmedabad, aimed at diploma students in Information and Communication Technology for the academic term 2025-26. It outlines the vision and mission of the Directorate of Technical Education and the institute, details the course structure, practical outcomes, and assessment methods, and emphasizes the importance of hands-on experience in developing relevant skills. The manual includes a variety of practical exercises designed to enhance students' programming competencies and prepare them for industry demands.

Uploaded by

meera
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Diploma Engineering

Laboratory Manual
Python Programming
(DI02032011)

[ICT / 2ND SEM]


Enrolment No
Name
Branch Information & Communication Technology
Academic Term Even term 2025-26
Institute Government Polytechnic, Ahmedabad

Directorate Of Technical Education


Gandhinagar - Gujarat
Python Programming (DI02032011)
Python Programming (DI02032011)

DTE’s Vision:
● To provide globally competitive technical education;
● Remove geographical imbalances and inconsistencies;
● Develop student friendly resources with a special focus on girls’ education and
support to weaker sections;
● Develop programs relevant to industry and create a vibrant pool of technical
professionals.

Institute’s Vision:
To develop technically proficient and ethically sound diploma engineers
contributing to industry and society needs.

Institute’s Mission:
Institute Government Polytechnic, Gandhinagar strives,
❖ M1: To impart quality technical education.
❖ M2: To shape students towards sensitizing in ethical values and contributing
in nature.
❖ M3: To familiarize students with the world of work.

Department’s Vision:
To develop technically sound and ethically strong diploma Information and
Communication Technology engineers contributing to industry and society.

Department’s Mission:
❖ M1: To develop students’ proficiency in the field of Information and
Communication Technology engineering to serve the industry and society.
❖ M2: To focus on inculcating ethical values and contributory approach.
❖ M3: To provide effective teaching learning to students through continuous
faculty development.
Python Programming (DI02032011)
Python Programming (DI02032011)

Certificate

This is to certify that Mr./Ms ………………………………………………………………….


Enrollment No. ………….……………. of 2 Semester of Diploma in Information & Communication
Technology Engineering of Government Polytechnic Ahmedabad (617) has satisfactorily
completed the term work in course Python Programming (DI02032011) for the academic year:
2025-26 Term: Odd/Even prescribed in the GTU curriculum.

Place: …………………..

Date: …………………..

Signature of Course Faculty Head of the Department


Python Programming (DI02032011)
______________________________________________________________________________________
Python Programming (DI02032011)
______________________________________________________________________________________

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 -2021 (COGC-2021) 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 competency focused outcome- based Green
curriculum-2021. 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-centered 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.

Although we try our level best to design this lab manual, but always there are chances of
improvement. We welcome any suggestions for improvement.
Python Programming (DI02032011)
______________________________________________________________________________________

Programme Outcomes (POs) :

1. Basic and Discipline specific knowledge: Apply knowledge of basic mathematics, science and
engineering fundamentals and engineering specialization to solve the engineering problems.

2. Problem analysis: Identify and analyse well-defined engineering problems using codified
standard methods.

3. Design/ development of solutions: Design solutions for engineering well-defined technical


problems and assist with the design of systems components or processes to meet specified
needs.

4. Engineering Tools, Experimentation and Testing: Apply modern engineering tools and
appropriate technique to conduct standard tests and measurements.

5. Engineering practices for society, sustainability, and environment: Apply appropriate


technology in context of society, sustainability, environment and ethical practices.

6. Project Management: Use engineering management principles individually, as a team


member or a leader to manage projects and effectively communicate about well-defined
engineering activities.

7. Life-long learning: Ability to analyze individual needs and engage in updating in the context of
technological changes in field of engineering.
Python Programming (DI02032011)
______________________________________________________________________________________

Practical Outcome - Course Outcome matrix


Course Outcomes (COs):

CO1: Prepare flowchart and algorithm for solving computing problems.


CO2: Develop python programs to solve simple problems.
CO3: Apply control structure feature of python for developing programs.
CO4: Develop Python Programs using built-in functions, modules, and libraries.
CO5: Develop python programs using dictionary, list, string, set and tuple manipulation functions.

C CO2 CO3 CO4 CO5


S. Practical Outcome/Title of experiment O
No. 1

1. Prepare flowchart and algorithm for a given


problem.
i. Find the sum of two given numbers. √
ii. Find a maximum out of two given numbers.
iii. Find whether a given number is odd or even.
iv. Find a maximum out of three given numbers.
2. a) Write a Program to print your name, mobile √
number, and date of birth.
b) Develop a Program to identify data-types in
python.
a) Create a Program to read three numbers √
3. from the user and find the average of the
numbers.
b) Develop a Program that can calculate simple
interest and compound interest on given data.
c) Write a Program to convert temperature
from Fahrenheit to Celsius unit using eq: C=(F-
32)/1.8
4. a) Identify whether the scanned number is even √
or odd and print an appropriate message.
b) Create a Program to find a maximum number
among the given three numbers.
5. Develop a Program to demonstrate the basic √
functionalities of a standard calculator.

6. a) Write a Python program to print 1 to 10



numbers using loops.
b) Write a Program to show whether the
entered number is prime or not
7. Write a Program to display the following

patterns.
Python Programming (DI02032011)
______________________________________________________________________________________

A) B)
1 *****
12 ****
123 ***
1234 **
12345 *
8. Create a User-defined function to print the

Fibonacci series of 0 to N numbers. (Where N
is an integer number and passed as an
argument)

9.
a) Develop a User-defined function to find the

factorial of a given number.
b) Write a Program using the function that
reverses the entered
value.
Write a Program that determines whether a

10. given number is an ‘Armstrong number’ or a
palindrome using a user-defined function.

a) Write a Program to find the length of a



11. string.
b) Write a Program to reverse words in a
given sentence.
c) Write a Program to check if a substring is
present in a given string.
d) Write a Program to count and display the
number of vowels, consonants, uppercase,
lowercase characters in a string.
Develop Programs to perform the following

12. list operations.
a) To swap given two elements in a list.
b) To find the sum of elements in a list.
c) To check if an element exists in a given list.
d) To find the smallest and largest element in
a given list.
a) Given a List saved in variable: a = [1, 4, 9, √
13. 16, 25, 36, 49, 64, 81, 100]. Write one line of
Python that takes this list and makes a new
Python Programming (DI02032011)
______________________________________________________________________________________

list that has only the even elements of this list


in it.
b) Create a List containing the square of all
odd numbers from range 1 to 10.
c) Create a List of prime and non-prime
numbers in range 1 to 50.
a) Write a Program to demonstrate some

14. useful set functions and operations.
b) Write a Program to demonstrate some
useful Tuple functions and operations.
a) Write a Program to demonstrate the

15. dictionaries functions and operations.
b) Create a Dictionary with the roll number,
name, and marks of n students in a class and
display the names of students who have
scored marks above 75
Python Programming (DI02032011)
______________________________________________________________________________________

Industry Relevant Skills

The following industry relevant skills are expected to be developed in the students by performance of
experiments of this course.

1. Able to develop any application using python language.


2. Create a professional program using python.

Guidelines to Course Faculty


1. Couse faculty should demonstrate experiment with all necessary implementation strategies
described in curriculum.
2. Couse faculty should explain industrial relevance before starting of each experiment.
3. Course faculty should Involve & give opportunity to all students for hands on experience.
4. Course faculty should ensure mentioned skills are developed in the students by asking.
5. Utilise 2 hrs of lab hours effectively and ensure completion of write up with quiz also.
6. Encourage peer to peer learning by doing same experiment through fast learners.

Instructions for Students

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.
Python Programming (DI02032011)
______________________________________________________________________________________

Continuous Assessment Sheet


Students Name: Enrolment No:
Subject Name with code:
Faculty Name:

Sr Practical Outcome/Title of experiment Marks


no Page Sign
Date (25)

1. Prepare flowchart and algorithm for a given


problem.
i. Find the sum of two given numbers.
ii. Find a maximum out of two given numbers.
iii. Find whether a given number is odd or even.
iv. Find a maximum out of three given numbers.
2. a) Write a Program to print your name, mobile
number, and date of birth.
b) Develop a Program to identify data-types in
python.
a) Create a Program to read three numbers from
3. the user and find the average of the numbers.
b) Develop a Program that can calculate simple
interest and compound interest on given data.
c) Write a Program to convert temperature from
Fahrenheit to Celsius unit using eq: C=(F-32)/1.8
4. a) Identify whether the scanned number is even
or odd and print an appropriate message.
b) Create a Program to find a maximum number
among the given three numbers.
5. Develop a Program to demonstrate the basic
functionalities of a standard calculator.

6.
a) Write a Python program to print 1 to 10
numbers using loops.
b) Write a Program to show whether the
entered number is prime or not
7. Write a Program to display the following
patterns.
A) B)
1 *****
12 ****
123 ***
1234 **
12345 *
Python Programming (DI02032011)
______________________________________________________________________________________

8. Create a User-defined function to print the


Fibonacci series of 0 to N numbers. (Where N is
an integer number and passed as an argument)

9.
a) Develop a User-defined function to find the
factorial of a given number.
b) Write a Program using the function that
reverses the entered
value.
Write a Program that determines whether a
10. given number is an ‘Armstrong number’ or a
palindrome using a user-defined function.

a) Write a Program to find the length of a string.


11. b) Write a Program to reverse words in a given
sentence.
c) Write a Program to check if a substring is
present in a given string.
d) Write a Program to count and display the
number of vowels, consonants, uppercase,
lowercase characters in a string.
Develop Programs to perform the following list
12. operations.
a) To swap given two elements in a list.
b) To find the sum of elements in a list.
c) To check if an element exists in a given list.
d) To find the smallest and largest element in a
given list.
a) Given a List saved in variable: a = [1, 4, 9, 16,
13. 25, 36, 49, 64, 81, 100]. Write one line of Python
that takes this list and makes a new list that has
only the even elements of this list in it.
b) Create a List containing the square of all odd
numbers from range 1 to 10.
c) Create a List of prime and non-prime
numbers in range 1 to 50.
a) Write a Program to demonstrate some
14. useful set functions and operations.
b) Write a Program to demonstrate some
useful Tuple functions and operations.
a) Write a Program to demonstrate the
15. dictionaries functions and operations.
b) Create a Dictionary with the roll number,
name, and marks of n students in a class and
display the names of students who have
scored marks above 75
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No. 1: Prepare flowchart and algorithm for a given problem.


i. Find the sum of two given numbers.
ii. Find a maximum out of two given numbers.
iii. Find whether a given number is odd or even.
iv. Find a maximum out of three given numbers
A. Objective:
Student will able to write/draw flowchart and algorithm for given problem.
B. Expected Program Outcomes (POs)
a. Basic knowledge: Apply knowledge of basic mathematics, sciences and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline- specificknowledge
to solve core computer engineering related problems.
c. Engineering tools: Apply relevant Computer technologies and tools with an
understanding of the limitations.
d. Communication: Communicate effectively in oral and written form.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the Computer engineering field and allied industry.
C. Competency and Practical Skills
Develop general solution to given problem using following methods:

a. Draw flow chart for given problem.


b. Write Algorithm to solve given problem.

D. Expected Course Outcome(s)


Prepare flowchart and algorithm for solving computing problems.

E. Practical Outcomes (PrOs)


Prepare flowchart and algorithm for a given problem.

F. Prerequisite Theory:

An introduction to Algorithm

What is Algorithm?

The word Algorithm means “a process or set of rules to be followed in calculations or other
problem-solving operations”. Therefore, Algorithm refers to a set of rules/instructions that step-by-step
define how a work is to be executed upon in order to get the expected results.

1|Page
Python Programming (DI02032011)
______________________________________________________________________________________

It can be understood by taking an example of cooking a new recipe. To cook a new recipe, one
reads the instructions and steps and execute them one by one, in the given sequence. The result thus
obtained is the new dish cooked perfectly. Similarly, algorithms help to do a task in programming to get
the expected output.

The Algorithm designed are language-independent, i.e. they are just plain instructions that can
be implemented in any language, and yet the output will be the same, as expected.

How to Design an Algorithm?

In order to write an algorithm, following things are needed as a pre-requisite:

1. The problem that is to be solved by this algorithm.


2. The constraints of the problem that must be considered while solving the problem.
3. The input to be taken to solve the problem.
4. The output to be expected when the problem the is solved.
5. The solution to this problem, in the given constraints.
Algorithm to add 3 numbers and print their sum:
Step 1. START
Step 2. Declare 3 integer variables num1, num2 and num3.
Step 3. Take the three numbers, to be added, as inputs in variables num1, num2, and num3
respectively.
Step 4. Declare an integer variable sum to store the resultant sum of the 3 numbers.
Step 5. Add the 3 numbers and store the result in the variable sum.
Step 6. Print the value of variable sum
Step 7. END

What is a Flowchart?

Flowchart is a graphical representation of an algorithm. Programmers often use it as a program-planning


tool to solve a problem. It makes use of symbols which are connected among them to indicate the flow
of information and processing. The process of drawing a flowchart for an algorithm is known as
“flowcharting”.
Basic Symbols used in Flowchart Designs

2|Page
Python Programming (DI02032011)
______________________________________________________________________________________

1. Terminal: The oval symbol indicates Start, Stop and Halt in a program’s logic flow. A
pause/halt is generally used in a program logic under some error conditions. Terminal is the
first and last symbols in the flowchart.

2. Input/Output: A parallelogram denotes any function of input/output type. Program


instructions that take input from input devices and display output on output devices are
indicated with parallelogram in a flowchart.

3. Processing: A box represents arithmetic instructions. All arithmetic processes such as


adding, subtracting, multiplication and division are indicated by action or process symbol.

4. Decision Diamond symbol represents a decision point. Decision based operations such as
yes/no question or true/false are indicated by diamond in flowchart.

5. Connectors: Whenever flowchart becomes complex or it spreads over more than one
page, it is useful to use connectors to avoid any confusions. It is represented by a circle.

6. Flow lines: Flow lines indicate the exact sequence in which instructions are executed.
Arrows represent the direction of flow of control and relationship among different symbols
of flowchart.

3|Page
Python Programming (DI02032011)
______________________________________________________________________________________

7. Subroutine: This symbol is used for user defined function or sub program.

8. Page Break: When flowchart does not fit into single page then page break and page
continue symbols are used.
Page Break symbol indicate break in current page.

9. Page Continue
Page continue symbol indicate continue flowchart in another page.

Example : Draw a flowchart to input two numbers from user and display the largest of two numbers

4|Page
Python Programming (DI02032011)
______________________________________________________________________________________

Attach Your Exercise along with output with this practical.

G. References:
1. [Link]

H. Flow Chart/Code:
i. Find the sum of two given numbers.

5|Page
Python Programming (DI02032011)
______________________________________________________________________________________

ii. Find a maximum out of two given numbers.

6|Page
Python Programming (DI02032011)
______________________________________________________________________________________

iii. Find whether a given number is odd or even.

7|Page
Python Programming (DI02032011)
______________________________________________________________________________________

iv. Find a maximum out of three given numbers

8|Page
Python Programming (DI02032011)
______________________________________________________________________________________

I. Assessment Scheme :
Criteria Assessment scale Obtained points
Technical Skills: 5 point - Demonstrates mastery of technical skills and can
use them to solve complex problems.
4 point - Demonstrates proficiency in technical skills and
can use them to solve simple problems.
3 point - Demonstrates basic competency in technical skills
but struggles with more complex tasks.
2 point - Demonstrates limited competency in technical
skills and requires significant assistance.
1 point- Does not demonstrate competency in technical
skills.
Work Quality: 5 point - Produces work that is of exceptional quality and
meets all requirements.
4 point - Produces work that is of good quality and meets
most requirements.
3 point - Produces work that meets some requirements but
requires revision or improvement.
2 point - Produces work that does not meet most
requirements and requires significant revision or
improvement.
1 point - Does not produce work that meets any
requirements.
Collaboration: 5 point - Works effectively with partners or in a group
setting, communicates well, and contributes equally.
4 point - Works well with partners or in a group setting,
communicates effectively, and contributes fairly.
3 point - Works adequately with partners or in a group
setting, communicates somewhat effectively, and
contributes unequally.
2 point - Struggles to work with partners or in a group
setting, communicates poorly, and does not contribute
equally.
1 point - Does not work well with partners or in a group
setting, communicates poorly, and does not contribute.

Initiative: 5 point - Takes initiative to explore new concepts and tools,


goes beyond requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and
tools, meets requirements, and produces good work.
3 point - Occasionally takes initiative to explore new
concepts and tools, but requires guidance and produces work
that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and
tools, requires significant guidance, and produces work that
does not meet most requirements.
1 point - Does not take initiative to explore new concepts
and tools, requires constant guidance, and does not meet
any requirements.

Total : /20
Sign with date:

9|Page
Python Programming (DI02032011)
______________________________________________________________________________________

10 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No.2:
a) Write a Program to print your name, mobile number, and date of birth.
b) Develop a Program to identify data-types in python.
A. Objective: Program to display message on screen.

B. Expected Program Outcomes (POs):


a. Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c. Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to write a basic program of python to using mathematical equation.

D. Expected Course Outcomes (Cos)


CO2: Develop python programs to solve simple problems.

E. Practical Outcome (PRo) :


a) Write a Program to print your name, mobile number, and date of birth.
b) Develop a Program to identify data-types in python.

F. Prerequisite Theory:
When you run this program, it will print the message "Hello, world!" to the screen. You can modify
the message to display any other text that you want.

Python Code:

# This program displays a message on the screen

print("Hello, world!")

Output:
Hello, world!
Data Types:

11 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Every value in Python has a data type. Since everything is an object in Python programming, data
types are classes, and variables are instance (object) of these classes. There are various data types
in Python. Some of the important types are listed below.
DATA TYPES IN PYTHON
• Python Numbers
• Python List
• Python Tuple
• Python Strings
• Python Set
• Python Dictionary

Chart : Python Data Types


Python Data Type – Numeric
Python numeric data type is used to hold numeric values like;

Data Type Use

Int holds signed integers of non-limited length.

Long holds long integers(exists in Python 2.x,

Float holds floating precision numbers and it’s

complex holds complex numbers.

Python Data Type – String


String is a sequence of characters. Python supports Unicode [Link]
strings are represented by either single or double quotes.

>>> s1 = "This is a string"

12 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

>>> s2= '''a multiline String'''

Single Line “Hello world”


String

Multi Line “”” Gwalior


String
Madhya Pradesh”””

Raw String r"raw \n string" [ Used when we want to have a string that contains
backslash and don’t want it to be treated as an escape character.]

Character "C" [ Single letter]

Unicode ं
u"\u0938\u0902\u0917\u0940\u0924\u093E" will print 'सग
string ं तं '

Python Data type- List

List is a versatile data type exclusive in Python. In a sense it is same as array in


C/C++. But interesting thing about list in Python is it can simultaneously hold
different type of data.
Formally list is a ordered sequence of some data written using squarerackets
([]) and commas (,)

13 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Python Tuple

Tuple is an ordered sequences of items same as list. The only difference is that
tuples are immutable. Tuples once created cannot be modified.
Tuples are used to write-protect data and are usually faster than list as it cannot
change dynamically. It is defined within parentheses () where items are
separated by commas
>>> t = (50,'Learning is fun', 1+3j, 45.67) # Can store mixed data types

Advantages of Tuple over List


➢ Since tuple are immutable, iterating through tuple is faster than with list. So
there is a slight performance boost.
➢ We generally use tuple for heterogeneous (different) datatypes and list for
homogeneous (similar) datatypes.
➢ Tuples that contain immutable elements can be used as key for a dictionary.
With list, this is not possible.
➢ If you have data that doesn't change, implementing it as tuple will guarantee
that it remains write-protected.
Python Set

Set is an unordered collection of unique items. Set is defined by


valuesseparated by comma inside braces { }.Items in a set are not
ordered.
a = {5,2,3,1,4}

printing set variable


print("a = ", a)

data type of variable a


print(type(a)) # <class 'set'>
1. Python Dictionary
Dictionary is an unordered collection of key-value pairs.
It is generally used when we have a huge amount of data. Dictionaries are
optimized for retrieving data. We must know the key to retrieve the value.
In Python, dictionaries are defined within Curly braces {} with each item being
a pair in the form key: value.

14 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Key and value can be of any type.

Python Code:

# This program displays a message on the screen


x=5
print(type(x))

Output:
<class 'int'>

Print and attach Your Code along with output with this practical.
G. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No /Components/Trainer
. kit

15 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

H. Code (with output):


a) Write a Program to print your name, mobile number, and date of birth.

b) Develop a Program to identify data-types in python.

I. References:
1. [Link]
2. [Link]
16 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

J. Assessment Scheme
Criteria Assessment scale Obtained
points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them
to solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical
skills and requires significant assistance.
1 point- Does not demonstrate competency in technical
skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most
requirements.
Work Quality: 3 point - Produces work that meets some requirements but requires
revision or improvement.
2 point - Produces work that does not meet most requirements and
requires significant revision or improvement.
1 point - Does not produce work that meets any requirements.
5 point - Works effectively with partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting,
communicates poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools,
Initiative: but requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools,
requires significant guidance, and produces work that does not meet
most requirements.
1 point - Does not take initiative to explore new concepts and tools,
requires constant guidance, and does not meet any requirements.

Total : /20
Sign with date:

17 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

18 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No.3:
a) Create a Program to read three numbers from the user and find the average of the
numbers.
b) Develop a Program that can calculate simple interest and compound interest on
given data.
c) Write a Program to convert temperature from Fahrenheit to Celsius unit using eq:
C=(F- 32)/1.8
A. Objective: Program to read three numbers from the user and find the average of the
numbers.
B. Expected Program Outcomes (POs):
a. Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c. Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to write a basic program of python to using mathematical equation.

D. Expected Course Outcomes (Cos)


CO2.: Develop python programs to solve simple problems.

E. Practical Outcome (PRo) :


Student will able to write a basic program of python.
a) Create a Program to read three numbers from the user and find the average of the
numbers.
b) Develop a Program that can calculate simple interest and compound interest on given
data.
c) Write a Program to convert temperature from Fahrenheit to Celsius unit using eq: C=(F-
32)/1.8

F. Prerequisite Theory:
A. Create a Program to read three numbers from the user and find the average of the
numbers.

19 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

In Program To find the average of three numbers, you need to add up the three numbers and
then divide the sum by 3. Here's the logic in pseudocode:
1. Take three numbers as input from the user
2. Add the three numbers together
3. Divide the sum by 3 to get the average
4. Print the average

B. Develop a Program that can calculate simple interest and compound interest on given
data.
Simple Interest = (P * R * T) / 100
Where P is the principal amount
R is the rate of interest per annum
T is the time duration in years
Here is the logic in pseudocode to calculate Simple Interest:
1. Take the principal amount, rate of interest, and time duration as input from the user
2. Calculate the simple interest using the formula: (P * R * T) / 100
3. Print the simple interest.
Compound interest is calculated based on the principal amount, rate of interest, time period,
and the number of times the interest is compounded per year. The formula to calculate
compound interest is:
Compound Interest = P * (1 + (R / N)) ^ (N * T) - P
where, P is the principal amount
R is the annual interest rate
N is the number of times the interest is compounded per year
T is the time duration in years
Here's the logic in pseudocode to calculate compound interest:
1. Take the principal amount, rate of interest, time duration, and number of times interest is
compounded as input from the user
2. Calculate the compound interest using the formula: P * (1 + (R / N)) ^ (N * T) - P
3. Print the compound interest

C. Write a Program to convert temperature from Fahrenheit to Celsius unit using eq: C=(F-
32)/1.8
To convert a temperature from Celsius to Fahrenheit, you can use the formula:
F = (C * 9/5) + 32
Here's the logic in pseudocode to convert Celsius to Fahrenheit:
1. Take the temperature in Celsius as input from the user
2. Convert the temperature from Celsius to Fahrenheit using the formula: F = (C * 9/5) + 32
3. Print the temperature in Fahrenheit

Print and attach Your Code along with output with this practical.
G. Resources/Equipment Required

20 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Sr. Instrument/Equipment
Specification Quantity
No
/Components/Trainer
.
kit

H. Code (with output):


a) Create a Program to read three numbers from the user and find the average of
the numbers.

21 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

b) Develop a Program that can calculate simple interest and compound interest on
given data.

22 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

c) Write a Program to convert temperature from Fahrenheit to Celsius unit using


eq: C=(F- 32)/1.8

I. References:
1. [Link]
2. [Link]

23 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

J. Assessment Scheme:

Criteria Assessment scale Obtained


points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them
to solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical
skills and requires significant assistance.
1 point- Does not demonstrate competency in technical
skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most
requirements.
Work Quality: 3 point - Produces work that meets some requirements but requires
revision or improvement.
2 point - Produces work that does not meet most requirements and
requires significant revision or improvement.
1 point - Does not produce work that meets any requirements.
5 point - Works effectively with partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting,
communicates poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools,
Initiative: but requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools,
requires significant guidance, and produces work that does not meet
most requirements.
1 point - Does not take initiative to explore new concepts and tools,
requires constant guidance, and does not meet any requirements.

Total : /20
Sign with date:

24 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No.4:
a) Identify whether the scanned number is even or odd and print an appropriate
message.
b) Create a Program to find a maximum number among the given three numbers.
A. Objective: Program to read three numbers from the user and check it is odd or even and
find maximum of given three numbers.
B. Expected Program Outcomes (POs):
a. Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c. Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to write a program of python using if and else condition.

D. Expected Course Outcomes (Cos)


CO3: Apply control structure feature of python for developing programs.

E. Practical Outcome (PRo) :


Student will able to write a basic program of python.
a) Identify whether the scanned number is even or odd and print an appropriate message.
b) Create a Program to find a maximum number among the given three numbers.
F. Prerequisite Theory:
In Python, "if-else" is a conditional statement used to execute a block of code based on a
certain condition.
Here's the syntax:
if condition:
# code to be executed if condition is True
else:
# code to be executed if condition is False
Here, the "condition" is an expression that returns either True or False. If the condition is
True, then the code inside the "if" block will be executed, and if it's False, the code inside the
"else" block will be executed.

Here's an example:
25 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

x = 10
if x > 5:
print("x is greater than 5")
else:
print("x is less than or equal to 5")
In this example, the condition is "x > 5". Since the value of "x" is 10, the condition is True, so
the code inside the "if" block will be executed, and the output will be "x is greater than 5".

Print and attach Your Code along with output with this practical.
G. Resources/Equipment Required

Sr. Instrument/Equipment
Specification Quantity
No
/Components/Trainer
.
kit

H. Code (with output):


a) Identify whether the scanned number is even or odd and print an appropriate
message.

26 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

b) Create a Program to find a maximum number among the given three numbers.

I. References:
1. [Link]
2. [Link]
27 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

J. Assessment Scheme:

Criteria Assessment scale Obtained


points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them
to solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical
skills and requires significant assistance.
1 point- Does not demonstrate competency in technical
skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most
requirements.
Work Quality: 3 point - Produces work that meets some requirements but requires
revision or improvement.
2 point - Produces work that does not meet most requirements and
requires significant revision or improvement.
1 point - Does not produce work that meets any requirements.
5 point - Works effectively with partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting,
communicates poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools,
Initiative: but requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools,
requires significant guidance, and produces work that does not meet
most requirements.
1 point - Does not take initiative to explore new concepts and tools,
requires constant guidance, and does not meet any requirements.

Total : /20
Sign with date:

28 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No.5:
Develop a Program to demonstrate the basic functionalities of a standard calculator.
A. Objective: Program to Develop a Program to demonstrate the basic functionalities of a
standard calculator.
B. Expected Program Outcomes (POs):
a. Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c. Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to write a program of python using if and else condition.

D. Expected Course Outcomes (Cos)


CO3: Apply control structure feature of python for developing programs.

E. Practical Outcome (PRo) :


Student will able to write a program of python.
To demonstrate the basic functionalities of a standard calculator.
F. Prerequisite Theory:
In Python, The if-elif statement is shortcut of if..else chain. While using if-elif statement at
the end else block is added which is performed if none of the above if-elif statement is true.
Here's the syntax:
if condition:
# code to be executed if condition is True
elif condition:
# code to be executed if condition is True
elif condition:
# code to be executed if condition is True

.
.
.
else:
# code to be executed if condition is False
29 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Here, the "condition" is an expression that returns either True or False.

Here's an example:
# if-elif statement example
letter = "A"

if letter == "B":
print("letter is B")

elif letter == "C":


print("letter is C")

elif letter == "A":


print("letter is A")

else:
print("letter isn't A, B or C")

Print and attach Your Code along with output with this practical.
G. Resources/Equipment Required

Sr. Instrument/Equipment
Specification Quantity
No
/Components/Trainer
.
kit

30 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

H. Code (with output):


a) Develop a Program to demonstrate the basic functionalities of a standard
calculator.

I. References:
1. [Link]
2. [Link]

31 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

J. Assessment Scheme:
Criteria Assessment scale Obtained
points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them to
solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical skills and
requires significant assistance.
1 point- Does not demonstrate competency in technical
skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most
requirements.
Work Quality: 3 point - Produces work that meets some requirements but requires revision
or improvement.
2 point - Produces work that does not meet most requirements and requires
significant revision or improvement.
1
5 point
point- Does not produce
- Works work that
effectively withmeets any requirements.
partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting,
communicates poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools, but
Initiative: requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools, requires
significant guidance, and produces work that does not meet most
requirements.
1 point - Does not take initiative to explore new concepts and tools, requires
constant guidance, and does not meet any requirements.

Total : /20
Sign with date:

32 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No.6:
a) Write a Python program to print 1 to 10 numbers using loops.
b) Write a Program to show whether the entered number is prime or not.
A. Objective: Program to demonstrate the use of loop.
B. Expected Program Outcomes (POs):
a. Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c. Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to write a program of python using while and for loop.

D. Expected Course Outcomes (Cos)


CO3: Apply control structure feature of python for developing programs.

E. Practical Outcome (PRo) :


a) Write a Python program to print 1 to 10 numbers using loops.
b) Write a Program to show whether the entered number is prime or not.
F. Prerequisite Theory:
In Python, a for loop is a control flow statement that allows you to iterate over a sequence
of values such as a list, tuple, string, or range of numbers. The general syntax for a for loop
is:
for variable in sequence:
# code to be executed in each iteration
Here, variable is the name of the loop variable that takes on each value of the sequence in
each iteration of the loop. The sequence can be any iterable object such as a list, tuple, string,
or range object.
In each iteration of the loop, the code inside the loop body is executed with the loop variable
taking on the next value in the sequence until the end of the sequence is reached. Once the
loop has completed all iterations, the program continues executing the next line of code after
the loop.

33 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

You can use the break keyword to exit the loop prematurely and the continue keyword to
skip to the next iteration of the loop without executing the remaining code in the current
iteration.
In Python, a while loop is a control flow statement that allows you to execute a block of code
repeatedly while a specified condition is true. The general syntax for a while loop is:
while condition:
# code to be executed while condition is True
Here, condition is a Boolean expression that is evaluated before each iteration of the loop. If
the condition is True, the code inside the loop body is executed. Once the loop body has
executed, the condition is re-evaluated and the loop continues executing as long as the
condition remains True.
You can use the break keyword to exit the loop prematurely and the continue keyword to
skip to the next iteration of the loop without executing the remaining code in the current
iteration.
For example, the following code demonstrates a while loop that repeatedly prompts the user
to enter a number until a valid number is entered:
while True:
try:
num = int(input("Enter a number: "))
break
except ValueError:
print("Invalid number. Please try again.")
Here, the loop continues executing as long as the user enters an invalid number. Once a valid
number is entered, the loop is exited using the break keyword.

Print and attach Your Code along with output with this practical.
G. Resources/Equipment Required

Sr. Instrument/Equipment
Specification Quantity
No
/Components/Trainer
.
kit

34 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

H. Code (with output):


a) Write a Python program to print 1 to 10 numbers using loops.

35 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

b) Write a Program to show whether the entered number is prime or not.

I. References:
1. [Link]
2. [Link]
36 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

J. Assessment Scheme:
Criteria Assessment scale Obtained
points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them to
solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical skills and
requires significant assistance.
1 point- Does not demonstrate competency in technical skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most requirements.
3 point - Produces work that meets some requirements but requires revision
Work Quality: or improvement.
2 point - Produces work that does not meet most requirements and requires
significant revision or improvement.
1 point - Does not produce work that meets any requirements.
5 point - Works effectively with partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting, communicates
poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools, but
Initiative: requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools, requires
significant guidance, and produces work that does not meet most
requirements.
1 point - Does not take initiative to explore new concepts and tools, requires
constant guidance, and does not meet any requirements.

Total : /20
Sign with date:

37 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

38 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No.7: Write a Program to display the following patterns.


A) B)
1 *****
12 ****
123 ***
1234 **
12345 *

A. Objective: Program to demonstrate the use of loop.

B. Expected Program Outcomes (POs):


a. Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c. Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to write a program of python using for loop.

D. Expected Course Outcomes (Cos)


CO3: Apply control structure feature of python for developing programs.

E. Practical Outcome (PRo) :


Write a Python program to display the patterns.
F. Prerequisite Theory:
Python provides a variety of ways to print patterns using loops, conditionals, and string
manipulation. Here are some common techniques:
Using nested loops:
You can use nested loops to print patterns of stars, triangles, and other shapes. Here's an
example to print a square pattern of stars:
n=5
for i in range(n):
for j in range(n):
print('*', end='')
39 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

print()
Output:
*****
*****
*****
*****
*****
Using range function with step:
You can use the range function with a step to print patterns of numbers, letters, and other
characters. Here's an example to print a pattern of numbers:
n=5
for i in range(1, n+1):
print(str(i)*i)
Output:
1
22
333
4444
55555

Using string concatenation and slicing:


You can use string concatenation and slicing to print patterns of characters. Here's an
example to print a pattern of characters:
n=5
for i in range(1, n+1):
print(' '*(n-i) + '*'*i)
Output:
*
**
***
****
*****
These are just a few examples of the many ways you can print patterns using Python. The key
is to use your creativity and experiment with different techniques to achieve the desired
output.

Print and attach Your Code along with output with this practical.

G. Resources/Equipment Required

Sr. Instrument/Equipment
Specification Quantity
No
/Components/Trainer
.
kit

40 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

H. Code (with output):


A)
1
12
123
1234
12345

41 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

B)
*****
****
***
**
*

I. References:
1. [Link]
2. [Link]

42 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

J. Assessment Scheme:
Criteria Assessment scale Obtained
points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them to
solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical skills and
requires significant assistance.
1 point- Does not demonstrate competency in technical skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most requirements.
3 point - Produces work that meets some requirements but requires revision
Work Quality: or improvement.
2 point - Produces work that does not meet most requirements and requires
significant revision or improvement.
1 point - Does not produce work that meets any requirements.
5 point - Works effectively with partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting, communicates
poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools, but
Initiative: requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools, requires
significant guidance, and produces work that does not meet most
requirements.
1 point - Does not take initiative to explore new concepts and tools, requires
constant guidance, and does not meet any requirements.

Total : /20
Sign with date: ___________

43 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

44 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No.8: Create a User-defined function to print the Fibonacci series of 0 to


N numbers. (Where N is an integer number and passed as an argument).

A. Objective: Program to demonstrate the use of User Define Function.


B. Expected Program Outcomes (POs):
a. Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c. Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to write a program of python using User Define Function.

D. Expected Course Outcomes (Cos)


CO4: Develop Python Programs using built-in functions, modules, and libraries.

E. Practical Outcome (PRo) :


Write a Python program to create a User-defined function to print the Fibonacci series of 0 to
N numbers.

F. Prerequisite Theory:

In Python, a user-defined function is a block of reusable code that performs a specific task.
A user-defined function can be created using the def keyword, followed by the name of the
function and its parameters enclosed in parentheses. The body of the function is indented
below the def statement.
Here is the general syntax for creating a user-defined function in Python:
def function_name(parameter1, parameter2, ...):
# function body
# statements
return value

45 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

The parameter1, parameter2, and so on, are optional parameters that can be passed to the
function. These parameters are used to pass data to the function for processing. The return
statement is optional and is used to return a value from the function.
When a function is called, the arguments passed to the function are assigned to the
parameters in the function definition. The function then executes the statements in its body,
and if a return statement is encountered, the function returns the value specified by the
return statement.
The Fibonacci numbers are the numbers in the following integer sequence.
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..
In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence
relation
Fn = Fn-1 + Fn-2
with seed values
F0 = 0 and F1 = 1.

Print and attach Your Code along with output with this practical.

G. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No
/Components/Trainer
.
kit

46 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

H. Code (with output):


a) Create a User-defined function to print the Fibonacci series of 0 to N numbers.
(Where N is an integer number and passed as an argument).

I. References:
1. [Link]
2. [Link]

47 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

J. Assessment Scheme:
Criteria Assessment scale Obtained
points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them to
solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical skills and
requires significant assistance.
1 point- Does not demonstrate competency in technical skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most requirements.
3 point - Produces work that meets some requirements but requires revision
Work Quality: or improvement.
2 point - Produces work that does not meet most requirements and requires
significant revision or improvement.
1 point - Does not produce work that meets any requirements.
5 point - Works effectively with partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting, communicates
poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools, but
Initiative: requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools, requires
significant guidance, and produces work that does not meet most
requirements.
1 point - Does not take initiative to explore new concepts and tools, requires
constant guidance, and does not meet any requirements.

Total : /20
Sign with date: ___________

48 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No.9:
a) Develop a User-defined function to find the factorial of a given number.
b) Write a Program using the function that reverses the entered value.

A. Objective: Program to demonstrate the use of User Define Function.

B. Expected Program Outcomes (POs):


a. Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c. Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to write a program of python using User Define Function.

D. Expected Course Outcomes (Cos)


CO4: Develop Python Programs using built-in functions, modules, and libraries.

E. Practical Outcome (PRo) :


a) Develop a User-defined function to find the factorial of a given number.
b) Write a Program using the function that reverses the entered value.
F. Prerequisite Theory:
In Python, a user-defined function is a block of reusable code that performs a specific task.
A user-defined function can be created using the def keyword, followed by the name of the
function and its parameters enclosed in parentheses. The body of the function is indented
below the def statement.
Here is the general syntax for creating a user-defined function in Python:
def function_name(parameter1, parameter2, ...):
# function body
# statements
return value

49 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

The parameter1, parameter2, and so on, are optional parameters that can be passed to the
function. These parameters are used to pass data to the function for processing. The return
statement is optional and is used to return a value from the function.
When a function is called, the arguments passed to the function are assigned to the
parameters in the function definition. The function then executes the statements in its body,
and if a return statement is encountered, the function returns the value specified by the
return statement.
A) To find the factorial of a given number
The Factorial of a whole number 'n' is defined as the product of that number with every whole
number less than or equal to 'n' till 1. For example, the factorial of 4 is 4 × 3 × 2 × 1, which is
equal to 24.
B) To reverses the entered value.
First, the remainder of the num divided by 10 is stored in the variable digit. Now, the digit
contains the last digit of num, i.e. 4.
Digit is then added to the variable reversed after multiplying it by 10. Multiplication by 10
adds a new place in the reversed number. One-th place multiplied by 10 gives you tenth
place, tenth gives you hundredth, and so on. In this case, reversed_num contains 0 * 10 + 4
= 4.
num is then divided by 10 so that now it only contains the first three digits: 123.
After second iteration, digit equals 3, reversed equals 4 * 10 + 3 = 43 and num = 12.
After third iteration, digit equals 2, reversed equals 43 * 10 + 2 = 432 and num = 1.
After fourth iteration, digit equals 1, reversed equals 432 * 10 + 1 = 4321 and num = 0.
Now num = 0, so the test expression num != 0 fails and while loop exits. reversed already
contains the reversed number 4321.

Print and attach Your Code along with output with this practical.
G. Resources/Equipment Required

Sr. Instrument/Equipment
Specification Quantity
No
/Components/Trainer
.
kit

50 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

H. Code (with output):


a) Develop a User-defined function to find the factorial of a given number.

51 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

b) Write a Program using the function that reverses the entered value.

I. References:
1. [Link]
2. [Link]

52 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

J. Assessment Scheme:
Criteria Assessment scale Obtained
points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them to
solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical skills and
requires significant assistance.
1 point- Does not demonstrate competency in technical skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most requirements.
3 point - Produces work that meets some requirements but requires revision
Work Quality: or improvement.
2 point - Produces work that does not meet most requirements and requires
significant revision or improvement.
1 point - Does not produce work that meets any requirements.
5 point - Works effectively with partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting, communicates
poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools, but
Initiative: requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools, requires
significant guidance, and produces work that does not meet most
requirements.
1 point - Does not take initiative to explore new concepts and tools, requires
constant guidance, and does not meet any requirements.

Total : /20
Sign with date: ___________

53 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

54 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No.10: Write a Program that determines whether a given number is an


‘Armstrong number’ or a palindrome using a user-defined function.

A. Objective: Program to demonstrate the use of User Define Function.

B. Expected Program Outcomes (POs):


a. Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c. Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to write a program of python using User Define Function.

D. Expected Course Outcomes (Cos)


CO4: Develop Python Programs using built-in functions, modules, and libraries.

E. Practical Outcome (PRo) :


To determines whether a given number is an ‘Armstrong number’ or a palindrome using a
user-defined function.
F. Prerequisite Theory:
An Armstrong number is a number that is equal to the sum of its own digits each raised
to the power of the number of digits in the number. For example, 153 is an Armstrong
number because 1^3 + 5^3 + 3^3 = 153. To check if a given number is an Armstrong number
in Python, you can use the following code:
A Palindrome number is a number that remains the same when its digits are reversed. For
example, 121 is a palindrome number because its digits are the same when reversed. To
check if a given number is a palindrome number in Python.

Print and attach Your Code along with output with this practical.
G. Resources/Equipment Required

Sr. Instrument/Equipment
Specification Quantity
No
/Components/Trainer
.
kit

55 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

H. Code (with output):


a) Write a Program that determines whether a given number is an ‘Armstrong
number’ or a palindrome using a user-defined function.

56 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

I. References:
1. [Link]
2. [Link]

57 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

J. Assessment Scheme:
Criteria Assessment scale Obtained
points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them to
solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical skills and
requires significant assistance.
1 point- Does not demonstrate competency in technical skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most requirements.
3 point - Produces work that meets some requirements but requires revision
Work Quality: or improvement.
2 point - Produces work that does not meet most requirements and requires
significant revision or improvement.
1 point - Does not produce work that meets any requirements.
5 point - Works effectively with partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting, communicates
poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools, but
Initiative: requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools, requires
significant guidance, and produces work that does not meet most
requirements.
1 point - Does not take initiative to explore new concepts and tools, requires
constant guidance, and does not meet any requirements.

Total : /20
Sign with date: ___________

58 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No.11:
a) Write a Program to find the length of a string.
b) Write a Program to reverse words in a given sentence.
c) Write a Program to check if a substring is present in a given string.
d) Write a Program to count and display the number of vowels, consonants,
uppercase, lowercase characters in a string.

A. Objective: Program to demonstrate the use of different string functions and operations.

B. Expected Program Outcomes (POs):


a. Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c. Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to write a program of python using string function.

D. Expected Course Outcomes (Cos)


CO5: Develop python programs using dictionary, list, string, set and tuple manipulation
functions.

E. Practical Outcome (PRo) :


To demonstrate different string functions and methods for string operations.
F. Prerequisite Theory:
Strings in python are surrounded by either single quotation marks, or double quotation
marks.
'hello' is the same as "hello".
Slicing:
You can return a range of characters by using the slice syntax.
Specify the start index and the end index, separated by a colon, to return a part of the string.
b = "Hello, World!"
59 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

print(b[2:5])
Output: llo

b = "Hello, World!"
print(b[-5:-2])
Output:orl
Split:
The split() method returns a list where the text between the specified separator becomes the
list items.
a = "Hello, World!"
b = [Link](",")
print(b)
Output: ['Hello', ' World!']
Python has a set of built-in methods that you can use on strings.
Function Name Description
Converts the first character of the string to a capital (uppercase)
capitalize()
letter
casefold() Implements caseless string matching
center() Pad the string with the specified character.
count() Returns the number of occurrences of a substring in the string.
encode() Encodes strings with the specified encoded scheme
endswith() Returns “True” if a string ends with the given suffix
Specifies the amount of space to be substituted with the “\t”
expandtabs()
symbol in the string
find() Returns the lowest index of the substring if it is found
format() Formats the string for printing it to console
format_map() Formats specified values in a string using a dictionary
Returns the position of the first occurrence of a substring in a
index()
string
Checks whether all the characters in a given string is alphanumeric
isalnum()
or not
isalpha() Returns “True” if all characters in the string are alphabets
isdecimal() Returns true if all characters in a string are decimal
isdigit() Returns “True” if all characters in the string are digits
isidentifier() Check whether a string is a valid identifier or not
islower() Checks if all characters in the string are lowercase
isnumeric() Returns “True” if all characters in the string are numeric characters
Returns “True” if all characters in the string are printable or the
isprintable()
string is empty
Returns “True” if all characters in the string are whitespace
isspace()
characters
istitle() Returns “True” if the string is a title cased string
isupper() Checks if all characters in the string are uppercase
join() Returns a concatenated String
ljust() Left aligns the string according to the width specified

60 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

lower() Converts all uppercase characters in a string into lowercase


lstrip() Returns the string with leading characters removed
maketrans() Returns a translation table
partition() Splits the string at the first occurrence of the separator
replace() Replaces all occurrences of a substring with another substring
rfind() Returns the highest index of the substring
rindex() Returns the highest index of the substring inside the string
rjust() Right aligns the string according to the width specified
rpartition() Split the given string into three parts
rsplit() Split the string from the right by the specified separator
rstrip() Removes trailing characters
splitlines() Split the lines at line boundaries
startswith() Returns “True” if a string starts with the given prefix
strip() Returns the string with both leading and trailing characters
swapcase() Converts all uppercase characters to lowercase and vice versa
title() Convert string to title case
translate() Modify string according to given translation mappings
upper() Converts all lowercase characters in a string into uppercase
Returns a copy of the string with ‘0’ characters padded to the left
zfill()
side of the string

Print and attach Your Code along with output with this practical.
G. Resources/Equipment Required

Sr. Instrument/Equipment
Specification Quantity
No
/Components/Trainer
.
kit

H. Code (with output):


a) Write a Program to find the length of a string.

61 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

b) Write a Program to reverse words in a given sentence.

62 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

c) Write a Program to check if a substring is present in a given string.

63 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

d) Write a Program to count and display the number of vowels, consonants,


uppercase, lowercase characters in a string.

I. References:
1. [Link]
2. [Link]

64 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

J. Assessment Scheme:
Criteria Assessment scale Obtained
points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them to
solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical skills and
requires significant assistance.
1 point- Does not demonstrate competency in technical skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most requirements.
3 point - Produces work that meets some requirements but requires revision
Work Quality: or improvement.
2 point - Produces work that does not meet most requirements and requires
significant revision or improvement.
1 point - Does not produce work that meets any requirements.
5 point - Works effectively with partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting, communicates
poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools, but
Initiative: requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools, requires
significant guidance, and produces work that does not meet most
requirements.
1 point - Does not take initiative to explore new concepts and tools, requires
constant guidance, and does not meet any requirements.

Total : /20
Sign with date: ___________

65 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

66 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No.12: Develop Programs to perform the following list operations.


a) To swap given two elements in a list.
b) To find the sum of elements in a list.
c) To check if an element exists in a given list.
d) To find the smallest and largest element in a given list.

A. Objective: Program to demonstrate the use of different list methods and operations.

B. Expected Program Outcomes (POs):


a. Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c. Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to write a program of python using List methods.

D. Expected Course Outcomes (Cos)


CO5: Develop python programs using dictionary, list, string, set and tuple manipulation
functions.

E. Practical Outcome (PRo) :


To demonstrate different list operations using list methods.
F. Prerequisite Theory:
Lists are used to store multiple items in a single variable.
Lists are one of 4 built-in data types in Python used to store collections of data, the other 3
are Tuple, Set, and Dictionary, all with different qualities and usage.
Lists are created using square brackets e.g. thislist = ["apple", "banana", "cherry"]
List items are ordered, changeable, and allow duplicate values. List items are indexed, the
first item has index [0], the second item has index [1] etc. If you add new items to a list, the
new items will be placed at the end of the list.
Python has a set of built-in methods that you can use on lists.

67 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Method Description
append() Adds an element at the end of the list
clear() Removes all the elements from the list
copy() Returns a copy of the list
count() Returns the number of elements with the specified value
extend() Add the elements of a list (or any iterable), to the end of the current list
index() Returns the index of the first element with the specified value
insert() Adds an element at the specified position
pop() Removes the element at the specified position
remove() Removes the item with the specified value
reverse() Reverses the order of the list
sort() Sorts the list

Print and attach Your Code along with output with this practical.
G. Resources/Equipment Required

Sr. Instrument/Equipment
Specification Quantity
No
/Components/Trainer
.
kit

H. Code (with output):


a) To swap given two elements in a list.

68 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

b) To find the sum of elements in a list.

69 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

c) To check if an element exists in a given list.

70 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

d) To find the smallest and largest element in a given list.

I. References:
1. [Link]
2. [Link]
71 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

J. Assessment Scheme:
Criteria Assessment scale Obtained
points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them to
solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical skills and
requires significant assistance.
1 point- Does not demonstrate competency in technical skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most
requirements.
Work Quality: 3 point - Produces work that meets some requirements but requires revision
or improvement.
2 point - Produces work that does not meet most requirements and requires
significant revision or improvement.
1 point
5 point- Does not produce
- Works work that
effectively withmeets any requirements.
partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting,
communicates poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools, but
Initiative: requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools, requires
significant guidance, and produces work that does not meet most
requirements.
1 point - Does not take initiative to explore new concepts and tools, requires
constant guidance, and does not meet any requirements.

Total : /20
Sign with date: ___________

72 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No.13:
a) Given a List saved in variable: a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]. Write one line
of Python that takes this list and makes a new list that has only the even elements of
this list in it.
b) Create a List containing the square of all odd numbers from range 1 to 10.
c) Create a List of prime and non-prime numbers in range 1 to 50.
d) To find the smallest and largest element in a given list.

A. Objective: Program to demonstrate the use of List Comprehension method.

B. Expected Program Outcomes (POs):


a. Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c. Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to write a program of python using List Comprehension methods.

D. Expected Course Outcomes (Cos)


CO5: Develop python programs using dictionary, list, string, set and tuple manipulation
functions.

E. Practical Outcome (PRo) :


To demonstrate different list operations using list Comprehension methods.
F. Prerequisite Theory:
List comprehension offers a shorter syntax when you want to create a new list based on the
values of an existing list.
Example:
Based on a list of fruits, you want a new list, containing only the fruits with the letter "a" in
the name.

Without list comprehension you will have to write a for statement with a conditional test
inside:
73 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

fruits = ["apple", "banana", "cherry", "kiwi", "mango"]


newlist = []

for x in fruits:
if "a" in x:
[Link](x)
print(newlist)
Output : ['apple', 'banana', 'mango']
With list comprehension you can do all that with only one line of code:
fruits = ["apple", "banana", "cherry", "kiwi", "mango"]
newlist = [x for x in fruits if "a" in x]
print(newlist)]
Output : ['apple', 'banana', 'mango']
newlist = [expression for item in iterable if condition == True]

Print and attach Your Code along with output with this practical.
G. Resources/Equipment Required

Sr. Instrument/Equipment
Specification Quantity
No
/Components/Trainer
.
kit

H. Code (with output):


a) Given a List saved in variable: a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]. Write
one line of Python that takes this list and makes a new list that has only the even
elements of this list in it.

74 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

b) Create a List containing the square of all odd numbers from range 1 to 10.

c) Create a List of prime and non-prime numbers in range 1 to 50.

75 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

d) To find the smallest and largest element in a given list.

I. References:
1. [Link]
2. [Link]

76 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

J. Assessment Scheme:
Criteria Assessment scale Obtained
points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them to
solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical skills and
requires significant assistance.
1 point- Does not demonstrate competency in technical skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most requirements.
3 point - Produces work that meets some requirements but requires revision
Work Quality: or improvement.
2 point - Produces work that does not meet most requirements and requires
significant revision or improvement.
1 point - Does not produce work that meets any requirements.
5 point - Works effectively with partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting, communicates
poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools, but
Initiative: requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools, requires
significant guidance, and produces work that does not meet most
requirements.
1 point - Does not take initiative to explore new concepts and tools, requires
constant guidance, and does not meet any requirements.

Total : /20
Sign with date: ___________

77 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

78 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No.14:
a) Write a Program to demonstrate some useful set functions and operations.
b) Write a Program to demonstrate some useful Tuple functions and operations.

A. Objective: Program to demonstrate the use of set and tuple functions and operations.

B. Expected Program Outcomes (POs):


a. Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b. Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c. Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e. Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to demonstrate different set and tuple function.

D. Expected Course Outcomes (Cos)


CO5: Develop python programs using dictionary, list, string, set and tuple manipulation
functions.

E. Practical Outcome (PRo) :


To demonstrate different set and tuple operations.
F. Prerequisite Theory:

Python Set:
Sets are used to store multiple items in a single variable. A set is a collection which is
unordered, unchangeable, and unindexed. Sets are written with curly brackets. Set items are
unordered, unchangeable, and do not allow duplicate values. Sets are unordered, so you
cannot be sure in which order the items will appear. Sets cannot have two items with the
same value.
thisset = {"apple", "banana", "cherry"}
print(thisset)
output : {'cherry', 'apple', 'banana'}
Python has a set of built-in methods that you can use on sets.

Method Shortcut Description

79 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

add() Adds an element to the set


clear() Removes all the elements from the set
copy() Returns a copy of the set
Returns a set containing the difference between two or
difference() -
more sets
Removes the items in this set that are also included in
difference_update() -=
another, specified set
discard() Remove the specified item
intersection() & Returns a set, that is the intersection of two other sets
Removes the items in this set that are not present in other,
intersection_update() &=
specified set(s)
isdisjoint() Returns whether two sets have a intersection or not
issubset() <= Returns whether another set contains this set or not
Returns whether all items in this set is present in other,
<
specified set(s)
issuperset() >= Returns whether this set contains another set or not
Returns whether all items in other, specified set(s) is present
>
in this set
pop() Removes an element from the set
remove() Removes the specified element
symmetric_difference() ^ Returns a set with the symmetric differences of two sets
symmetric_difference_u Inserts the symmetric differences from this set and another
^=
pdate()
union() | Return a set containing the union of sets
update() |= Update the set with the union of this set and others

Python Tuple:
Tuples are used to store multiple items in a single variable. A tuple is a collection which is
ordered and unchangeable. Tuples are written with round brackets. When we say that tuples
are ordered, it means that the items have a defined order, and that order will not change.
Tuples are unchangeable, meaning that we cannot change, add or remove items after the
tuple has been created. Since tuples are indexed, they can have items with the same value.
thistuple = ("apple", "banana", "cherry", "apple", "cherry")
print(thistuple)
output : ('apple', 'banana', 'cherry', 'apple', 'cherry')
Python has two built-in methods that you can use on tuples.
Method Description
count() Returns the number of times a specified value occurs in a tuple
index() Searches the tuple for a specified value and returns the position of where it was found

Print and attach Your Code along with output with this practical.
G. Resources/Equipment Required

80 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Sr. Instrument/Equipment
Specification Quantity
No
/Components/Trainer
.
kit

H. Code (with output):


a) Write a Program to demonstrate some useful set functions and operations.

81 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

82 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

b) Write a Program to demonstrate some useful Tuple functions and operations.

83 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

84 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

I. References:
1. [Link]
2. [Link]
J. Assessment Scheme:
Criteria Assessment scale Obtained
points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them to
solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical skills and
requires significant assistance.
1 point- Does not demonstrate competency in technical skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most requirements.
3 point - Produces work that meets some requirements but requires revision
Work Quality: or improvement.
2 point - Produces work that does not meet most requirements and requires
significant revision or improvement.
1 point - Does not produce work that meets any requirements.
5 point - Works effectively with partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting, communicates
poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools, but
Initiative: requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools, requires
significant guidance, and produces work that does not meet most
requirements.
1 point - Does not take initiative to explore new concepts and tools, requires
constant guidance, and does not meet any requirements.

Total : /20
Sign with date: ___________

85 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

86 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Practical No. 15:


a) Write a Program to demonstrate the dictionaries functions and
operations.
b) Create a Dictionary with the roll number, name, and marks of n students
in a class and display the names of students who have scored marks above
75.
A. Objective: Program to demonstrate the dictionaries functions and operations.
B. . Expected Program Outcomes (POs):
a) Basic knowledge: Apply knowledge of basic mathematics, sciences, and basic
engineering to solve the broad-based Computer engineering problem.
b) Discipline knowledge: Apply Computer engineering discipline - specific knowledge
to solve core computer engineering related problems
c) Experiments and practice: Plan to perform experiments and practices to use the
results to solve broad-based Computer engineering problems.
d) Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
e) Life-long learning: Engage in independent and life-long learning activities in the
context of technological changes in the computer engineering field and allied
industry.

C. Expected Skills to be developed based on competency:


Student will able to write a program of python for different operation using dictionary feature in
python.

D. Expected Course Outcomes (Cos)


CO5: Develop python programs using dictionary, list, string, set and tuple manipulation functions.

E. Practical Outcome (PRo) :


Student will able to write a program of python for different operation using dictionary feature in
python.

F. Prerequisite Theory:
Python Dictionary:
Dictionaries are used to store data values in key:value pairs. A dictionary is a collection which is
ordered, mutable (with condition that dictionary values which are of mutable types are changeable
while dictionary values which are of immutable types cannot be changed) and do not allow
duplicates. Dictionaries are written with curly brackets, and have keys and values:
Create and print a dictionary:
87 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

Thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(thisdict)

O/P:

{'brand': 'Ford', 'model': 'Mustang', 'year': 1964}

Following are the dictionary methods

Method Description

clear() Removes all the elements from the dictionary

copy() Returns a copy of the dictionary

fromkeys() Returns a dictionary with the specified keys and value

get() Returns the value of the specified key

items() Returns a list containing a tuple for each key value pair

keys() Returns a list containing the dictionary's keys

pop() Removes the element with the specified key

popitem() Removes the last inserted key-value pair

Returns the value of the specified key. If the key does not exist: insert the key, with the
setdefault()
specified value

update() Updates the dictionary with the specified key-value pairs

values() Returns a list of all the values in the dictionary

G. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No
/Components/Trainer
.
kit

88 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

H. Code (with output):

a) Write a Program to demonstrate the dictionaries functions and


operations.

89 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

90 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

b) Create a Dictionary with the roll number, name, and marks of n


students in a class and display the names of students who have scored
marks above 75.

I. References:
1. [Link]
2. [Link]

91 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

J. Assessment Scheme:
Criteria Assessment scale Obtained
points
5 point - Demonstrates mastery of technical skills and can use them to
solve complex problems.
4 point - Demonstrates proficiency in technical skills and can use them to
solve simple problems.
Technical 3 point - Demonstrates basic competency in technical skills but struggles
Skills: with more complex tasks.
2 point - Demonstrates limited competency in technical skills and
requires significant assistance.
1 point- Does not demonstrate competency in technical skills.
5 point - Produces work that is of exceptional quality and meets all
requirements.
4 point - Produces work that is of good quality and meets most requirements.
3 point - Produces work that meets some requirements but requires revision
Work Quality: or improvement.
2 point - Produces work that does not meet most requirements and requires
significant revision or improvement.
1 point - Does not produce work that meets any requirements.
5 point - Works effectively with partners or in a groupsetting,
communicates well, and contributes equally.
4 point - Works well with partners or in a group setting, communicates
effectively, and contributes fairly.
3 point - Works adequately with partners or in a group setting,
Collaboration: communicates somewhat effectively, and contributes unequally.
2 point - Struggles to work with partners or in a group setting, communicates
poorly, and does not contribute equally.
1 point - Does not work well with partners or in a group setting,
communicates poorly, and does not contribute.
5 point - Takes initiative to explore new concepts and tools, goes beyond
requirements, and produces exceptional work.
4 point - Takes initiative to explore some new concepts and tools, meets
requirements, and produces good work.
3 point - Occasionally takes initiative to explore new concepts and tools, but
Initiative: requires guidance and produces work that meets basic requirements.
2 point - Rarely takes initiative to explore new concepts and tools, requires
significant guidance, and produces work that does not meet most
requirements.
1 point - Does not take initiative to explore new concepts and tools, requires
constant guidance, and does not meet any requirements.

Total: ____ /20


Sign with date: _______

92 | P a g e
Python Programming (DI02032011)
______________________________________________________________________________________

93 | P a g e

You might also like