0% found this document useful (0 votes)
2 views

Python_LabCourseFile20233docx__2024_09_18_12_49_13

The document is a checklist for a lab course in Programming in Python, detailing required contents such as course objectives, syllabus, and assessment plans. It outlines the institute's vision and mission, program educational objectives, and specific outcomes for students. Additionally, it includes a comprehensive course data sheet with assignments, textbooks, and proposed actions for syllabus gaps to meet industry requirements.

Uploaded by

xomawe6409
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python_LabCourseFile20233docx__2024_09_18_12_49_13

The document is a checklist for a lab course in Programming in Python, detailing required contents such as course objectives, syllabus, and assessment plans. It outlines the institute's vision and mission, program educational objectives, and specific outcomes for students. Additionally, it includes a comprehensive course data sheet with assignments, textbooks, and proposed actions for syllabus gaps to meet industry requirements.

Uploaded by

xomawe6409
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 67

Check-list for Lab Course

Sr. No. Contents Yes/No


1. Institute V/M; Department V/M/PEO; PO/PSO Statements
2. Academic Calendar
3. Lab Course Syllabus
4. Lab Course Data Sheet (with Complete details)
5. Lab Course Outcomes – Assessment Plan Sheet
6. Time Table of the Concerned Faculty Member
7. Detailed Lab Course Coverage
8. Lab Manuals
9. Quiz/Viva Sample Questions
10. Continuous Evaluation ( Lab Evaluation Sheets)
11. Sample Experiment Files (Two best , Two average & Two poor students)
12. Gaps & Plans for Add-on Experiments
13. Value Aided Experiments/Design Experiment/Open Ended Experiments
Any Innovative Method Adopted; Description
14.
(I.e. Projects/ charts/ PPTs/ Videos etc.)
15. Internal Awards Compilation Record (on Attached Performa)
16. Lab Course Outcomes Assessment (For NBA), Corrective Actions on CO Attainments

Prepared by: Checked by: Approved by


(Ms. Kavita Dhiman) (PAQIC Members) HOD
Institute Vision

"To emerge as the most preferred educational group with global recognition, developing competent
and socially sensitive leaders committed to excellence."

Institute Mission

To make incessant endeavour to translate our vision into a reality & achieve the following
objectives:

 To create world class facilities & ambiance for advance level of teaching and practical
training.
 To develop students as global citizens with conscience, commitment & education.
 To continuously grow & become fountain head among Institutes of Technical Higher
Education in India.
 To strengthen Industry-Institute Interface & promote Entrepreneurial development activities.
 To continuously strive for research, development & innovation in all relevant fields, thereby
providing the faculty & students the requisite platform to showcase their talents & win
laurels.
 To have collaboration with leading Universities of the world with a view to provide
opportunities to the students for higher studies & seek placement avenues abroad.
 To maintain the first position in placements in the North region, thereby ensuring that every
CGCians gets the best possible placement opportunities.
VISION

To provide imperative skills to students for meeting industry needs, and to become responsible
engineers, entrepreneurs and citizens.

MISSION

 To educate the students in the field of Computer-Science with ever-changing technologies


and skills.
 To enable the students in solving real-time problems and make use of new technologies.
 To have industry collaboration and interaction with professional societies for continuous
development.
 To help students in becoming successful entrepreneurs.
Program Educational Objectives (PEOs)

PEO 1: To impart core theoretical and practical knowledge of Computer applications for leading
successful career in industries, pursuing higher studies orentrepreneurial endeavors.

PEO 2: To develop the ability to critically think, analyze, design and develop software-based
solutions.

PEO 3: To imbibe the life-long learning and understanding of ethical values, their duties toward
environmental issues and sensitize them toward their social responsibilityas software developer.

Program Specific Outcomes (PSOs)

PSO 1: Able to acquire practical competency with emerging technologies and skillsneeded for
becoming an effective software developer.

PSO 2: Able to assess hardware and software aspects necessary to develop application software.
Program Outcomes (PO’s)

At the end of the Program, a graduate will be able to:

PO1: Basic knowledge: An ability to apply knowledge of basic mathematics, science and domain
knowledge to solve the computational problems.

PO2:Discipline knowledge: An ability to apply discipline –specific knowledge to solve core and/or
applied computational problems.

PO3:Experiments and practice: An ability to plan and perform experiments and practices and to
use the results to solve computational problems.

PO4:Tools Usage: Apply appropriate technologies and tools with an understanding oflimitations.

PO5:Profession and society: Demonstrate knowledge to assess societal, health, safety, legal and
cultural issues and the consequent responsibilities relevantto professional practice.

PO6:Environment and sustainability: Understand the impact of the computationalsolutions in


societal and environmental contexts, and demonstrate theknowledge and need for sustainable
development.

PO7:Ethics: Apply ethical principles and commit to professional ethics andresponsibilities and
norms of the professional practice.

PO8:Individual and team work: Function effectively as an individual, and as amember or leader
in diverse/multidisciplinary teams.

PO9:Communication: An ability to communicate effectively.

PO10: Life-long learning: Recognize the need for, and have the preparation andability to engage in
independent and life-long learning in the context oftechnological changes.

PO11:Problem Analysis: Identify, formulate, research literature, and solve complex computing
problem searching substantiated conclusions using fundamental principles of mathematics,
computing sciences, and relevant domain disciplines.

PO12:Innovation and Entrepreneurship: Identify a timely opportunity and using innovation to


pursue that opportunity to create value and wealth for the betterment of the individual and society at
large.
Faculty Sign HOD Sign
COURSE DATA SHEET
Course Code: UGCA1917
Course Name: Programming in Python Laboratory

Program: BCA L: 0 T: 0 P:4

Branch:ComputerApplications Credits:2
Semester:3rd Contacthours:4hoursperweek
Theory/Practical: Practical Percentage of numerical/design problems: 90%
Internalmax.marks:60 Duration of end semester exam (ESE):3hrs
Externalmax.marks:40 Elective status: Core
Total marks: 100

Prerequisite: -NA-
Co requisite: -NA-
Additional material required in ESE: -NA-
Course Outcomes
CO# Course outcomes
CO1 Outline various programming constructs like data types and control structures of Python.
CO2 Implement different data structures
CO3 Implement modules and functions.
CO4 Illustrate concept of object-oriented programming.
CO5 Implement file handling.

SYLLABUS:

S.no. Assignments
1 Computesum,subtraction, multiplication,divisionandexponentof givenvariables input by
the user.
2 Computeareaoffollowingshapes:circle,rectangle,triangle,square,trapezoid
andparallelogram.
3 Computevolumeoffollowing3Dshapes:cube,cylinder,coneand sphere.
4 Compute and print roots of quadratic equationax2+bx+c=0,wherethe valuesofa,b,
andcareinputbythe user.
5 Print numbers upto Nwhicharenotdivisibleby 3,6,9,,e.g., 1, 2,4, 5, 7,….
6 Write a program to determine whether a triangle is isoscelesornot?
7 Printmultiplication tableof anumberinputby the user
8 Computesumofnaturalnumbersfromonetonnumber.
9 PrintFibonacciseries upto nnumbers e.g.01 12358 13…..n
10 Computefactorialof agiven number.
11 Countoccurrenceofadigit5inagivenintegernumberinput by the user.
12 PrintGeometricand Harmonicmeansof aseriesinputbythe user.
13 Evaluatethefollowingexpressions:
x-x2 /2!+x3 /3!-x 4 /4!+…xn /n
b.!b. x-x 3/3!+x5 /5!-x 7/7!+… xn /n!
14 Printallpossiblecombinationsof4,5,and6.
15 Determineprimenumberswithin aspecificrange.
16 Count number of persons of age above 60 and below90
17 Computetransposeofa matrix.
18 Performfollowingoperationsontwomatrices.1)Addition2)Subtraction
3)Multiplication
19 Countoccurrenceofvowels
20 Counttotalnumberofvowelsin aword.
21 Determinewhetherastring ispalindromeornot.
22 Perform following operations on a list of numbers:
1)Insertanelement2)deleteanelement3)sortthelist4)deleteentirelist
23 DisplaywordafterSortinginalphabeticalorder
24 Performsequentialsearch onalistof givennumbers.
25 Performsequentialsearchonorderedlistofgivennumbers.
26 Maintainpracticalnotebookaspertheirserialnumbersinlibrary
usingPythondictionary
27 Performfollowingoperationsondictionary1)Insert2)delete3) change
28 Checkwhetheranumberisinagivenrangeusingfunctions.
29 Write a Python function that accepts a string andcalculatesnumberofuppercaseletters
andlowercaselettersavailable in that string.
30 TofindtheMaxofthreenumbersusingfunctions.
31 Multiplyall thenumbers inalistusing functions.
32 SolvetheFibonaccisequenceusingrecursion.
33 Get the factorial of a non-negative integer usingrecursion.
34 WriteaprogramtocreateamoduleoffactorialinPython.
35 Design a Python class named Rectangle, constructedby a length &width, also design a
method which willcomputethe areaofarectangle.
36 Design a Python class named Circle constructed by aradius and two methods which
will compute the areaandthe perimeter ofacircle.
37 DesignaPythonclasstoreverseastring‘wordbyword’.
38 WriteaPythonprogram toreadanentiretextfile.
39 DesignaPythonprogramtoreadfirstnlinesofatextfile.
40 ConstructaPythonprogramtowriteandappendtexttoa fileand display thetext.
Text Books

1. Programming in Python, Pooja Sharma, BPB Publications,2017.


2. Core Python Programming, R. Nageswara Rao, 2ndEdiiton,Dreamtech.

ReferenceBooks:
1. Python, The complete Reference, Martin C. Brown, Mc Graw HillEducation.
2. Python in a Nutshell, A. Martelli, A. Ravenscroft, S. Holden,OREILLY.

COURSE PRE-REQUISITES:
Prerequisite: -NA
Corequisite: -NA
Additional material required in ESE: -NA

COURSE OBJECTIVES:
1 Exposure to develop programming skills.
2 To understand basic concepts of Python programming.
3 To develop confidence towards other programming languages.

COURSE OUTCOMES:
At the end of this course student should be able to learn

SNo. DESCRIPTION PO(1..12) MAPPING


CO1
Outline various programming constructs like data types and PO(1,2,3,8,10,11)
control structures of Python.
CO2 Implement different data structures PO(1,2,3,8,10,11)
CO3 Implement modules and functions. PO(1,2,3,8,10,11)
CO4 Illustrate concept of object-oriented programming. PO(1,2,3,8,10,11)
CO5 Implement file handling. PO(1,2,3,8,10,11)

SNO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2
CO1 2 2 2 - - - - 1 - 1 1 - -
CO2 2 2 2 - - - - 1 - 1 1 - - -
CO3 2 2 2 - - - - 1 - 1 1 - - -
CO4 2 2 2 - - -` - 1 - 1 1 - -

OUTCOMES VS POS MAPPING (DETAILED; HIGH:3; MEDIUM:2; LOW:1):


* For Entire Course, PO /PSO Mapping; 1 (Low); 2(Medium); 3(High) Contribution to PO/PSO
PO1 Basic knowledge PO7 Ethics PSO1 ………………………….

PO2 Discipline knowledge PO8 Individual and team work PSO2 ………………………….
PO3 Experiments and practice PO9 Communication

PO4 Tools Usage PO10 Life-long learning

PO5 Profession and society PO11 Problem Analysis


Environment and Innovation and
PO6 PO12
sustainability Entrepreneurship

GAPES IN THE SYLLABUS - TO MEET INDUSTRY/PROFESSION REQUIREMENTS, POs:


SNO DESCRIPTION PROPOSED
ACTIONS
1 Python GUI Content Beyond syllabus
2 Tkinter concept Content Beyond syllabus, Extra Lectures
PROPOSED ACTIONS: TOPICS BEYOND SYLLABUS/ASSIGNMENT/INDUSTRY VISIT/GUEST LECTURER/NPTEL ETC

TOPICS BEYOND SYLLABUS/ADVANCED TOPICS/DESIGN:

1 Python GUI
2 Tkinter concept to develop web pages

WEB SOURCE REFERENCES:


1 htthttp://www.programiz.com/c-programming
2 htthttp://www.tutorialspoint.com/cprogramming/index.htm
3 htthttp://www.cprogramming.com/

DELIVERY/INSTRUCTIONAL METHODOLOGIES:

 CHALK & TALK, PPT STUD. ASSIGNMENT  WEB RESOURCES  NPTEL/OTHERS


 LCD/SMART STUD. SEMINARS ☐ ADD-ON COURSES ☐ WEBNIARS
BOARDS

ASSESSMENT METHODOLOGIES-DIRECT

ASSIGNMENTS STUD. SEMINARS  TESTS/MODEL  UNIV.


EXAMS EXAMINATION
 STUD. LAB ☐ STUD. VIVA ☐ MINI/MAJOR ☐ CERTIFICATIONS
PRACTICES PROJECTS
☐ ADD-ON COURSES ☐ OTHERS

ASSESSMENT METHODOLOGIES-INDIRECT
 ASSESSMENT OF COURSE OUTCOMES (BY  STUDENT FEEDBACK ON FACULTY
FEEDBACK, ONCE) (TWICE)
☐ ASSESSMENT OF MINI/MAJOR PROJECTS BY ☐ OTHERS
EXT. EXPERTS

INNOVATIONS IN TEACHING/LEARNING/EVALUATION PROCESSES:


1. Group Discussion.
2. PPT by students.
3. Open book test.
4. Online courses
5. MCQ’s

Prepared by Approved by
(Ms. Kavita Dhiman) HOD

VISION:

 Provide research-based and world-class computer education and training, and produce
ethically sound and technically competent versatile professionals.

MISSION:

 Develop the ability to adapt to technological skills to fulfill the challenges of the ever-
evolving global world.
 Induce knowledge that foster continuous improvement, self-learning, and innovation for
higher education.
 Create a unique organizational value-based culture, professionalism in education, service,
and management and learner-centered education of excellence.

PROGRAM EDUCATIONAL OBJECTIVES:

 To provide a foundation of business practices and computing principles to effectively


manage and use enterprise software and information systems.
 To acclimate the students with business software and help them to analyze the
requirements for developing systems.
 To provide the opportunity to specialize in system software, legacy application software
or mobile applications.

Subject: Programming in L T Total


Contac + =
Python (UGCA1917) rd 4 per 4 0 4
Semester:3 t
week
Branch: Computer Hours:
Faculty: Ms. Amandeep Kaur
Applications

Prerequisite Course: NA
Teacher Centric Approach TC1: Chalk and Talk, TC2: PPT, TC3: Video Lectures etc. (Add
any other as per our NIT Poly)
Learner Centric Approach: LC1: Assignment, LC2: Mini project, LC3: Quiz, LC 4: Seminar
on recent trends LC5: Group Task etc. (Add any other as per our NIT Poly)
Course
Lecture Proposed Actual
Topics/Sub Topics Outcome Remarks
No. Date Date
Addressed
1 Computesum,subtraction,
multiplication,divisionandexponentof CO1 25-7-23
givenvariables input by the user.
2 Computeareaoffollowingshapes:circle,rectangle
CO1 28-7-23
,triangle,square,trapezoid andparallelogram.
3 Computevolumeoffollowing3Dshapes:cube
CO1 01-8-23
,cylinder,coneand sphere.
4 Compute and print roots of quadratic
equationax2+bx+c=0,wherethe valuesofa,b, CO1 04-8-23
andcareinputbythe user.
5 Print numbers upto Nwhicharenotdivisibleby
CO2 08-8-23
3,6,9,,e.g., 1, 2,4, 5, 7,….
6 Write a program to determine whether a triangle is
CO2 08-8-23
isoscelesornot?
7 Printmultiplication tableof anumberinputby the
CO2 11-8-23
user
8 Computesumofnaturalnumbersfromoneton
CO2 18-8-23
number.
9 PrintFibonacciseries upto nnumbers e.g.01 12358
CO2 22-8-23
13…..n
10 Computefactorialof agiven number. CO2 25-8-23
11 Countoccurrenceofadigit5inagivenintegern
CO2 29-8-23
umberinput by the user.
12 PrintGeometricand Harmonicmeansof
CO2 29-8-23
aseriesinputbythe user.
13 Evaluatethefollowingexpressions: CO3
x-x2 /2!+x3 /3!-x 4 /4!+…xn /n 01-9-23
b.!b. x-x 3/3!+x5 /5!-x 7/7!+… xn /n!
14 Printallpossiblecombinationsof4,5,and6. CO3 05-9-23
15 Determineprimenumberswithin aspecificrange. CO3 05-9-23
16 Count number of persons of age above 60 and CO3
08-9-23
below90
17 Computetransposeofa matrix. CO3 12-9-23
18 Performfollowingoperationsontwomatrices.1 CO3
15-9-23
)Addition2)Subtraction 3)Multiplication
19 Countoccurrenceofvowels CO3 22-9-23
20 Counttotalnumberofvowelsin aword. CO3 22-9-23
21 Determinewhetherastring ispalindromeornot. CO3 26-9-23
22 Perform following operations on a list of numbers: CO3
1)Insertanelement2)deleteanelement3)sortthelist4) 29-9-23
deleteentirelist
23 DisplaywordafterSortinginalphabeticalorder CO3 3-10-23
24 Performsequentialsearch onalistof givennumbers. CO3 6-10-23
25 Performsequentialsearchonorderedlistofgiven CO3
6-10-23
numbers.
26 Maintainpracticalnotebookaspertheirserial CO3
10-10-23
numbersinlibrary usingPythondictionary
27 Performfollowingoperationsondictionary1)Insert2) CO3
13-10-23
delete3) change
28 Checkwhetheranumberisinagivenrangeusingf CO3
17-10-23
unctions.
29 Write a Python function that accepts a string CO3
andcalculatesnumberofuppercaseletters 20-10-23
andlowercaselettersavailable in that string.
30 TofindtheMaxofthreenumbersusingfunctions. CO3 27-10-23
31 Multiplyall thenumbers inalistusing functions. CO3 31-10-23
32 SolvetheFibonaccisequenceusingrecursion. CO3 04-11-23
33 Get the factorial of a non-negative integer CO3
04-11-23
usingrecursion.
34 WriteaprogramtocreateamoduleoffactorialinPytho CO3
07-11-23
n.
35 Design a Python class named Rectangle, CO4
constructedby a length &width, also design a 10-11-23
method which willcomputethe areaofarectangle.
36 Design a Python class named Circle constructed CO4
by aradius and two methods which will compute 14-11-23
the areaandthe perimeter ofacircle.
37 DesignaPythonclasstoreverseastring‘wordby CO4
17-11-23
word’.
38 WriteaPythonprogram toreadanentiretextfile. CO5 21-11-23
39 DesignaPythonprogramtoreadfirstnlinesofatextfil CO5
24-11-23
e.
40 ConstructaPythonprogramtowriteandappendtextt CO5
28-11-23
oa fileand display thetext.

Prepared by Approved by
(Ms. Kavita Dhiman) (HOD)
Practical -1
1. Compute Sum, Subtraction, Multiplication, Division and Exponent of given
variables input by the user.
a=int(input("Enter first value:"))
b=int(input("Enter second value:"))
add=a+b
print("Addition:",add)
sub=a-b
print("Subtraction:",sub)
mul=a*b
print("Multiplication:", mul)
div=a/b
print("Division", div)
exp=a**b
print("Exponent:",exp)
OUTPUT:
Enter first value:20
Enter second value:10
Addition: 30
Subtraction: 10
Multiplication: 200
Division 2.0
Exponent: 10240000000000
Practical -2
2. Compute area of following shapes: circle, rectangle triangle, square,
trapezoid and parallelogram.
print("Find area of following Shapes")
print('''1. Circle
2. Rectangle
3. Triangle
4. Square
5. Trapezoid
6. Parallelogram''')
choice = int(input("Enter the choice:-"))

if choice == 1:
from math import pi
radius = float(input("Enter the radius of circle->"))
area = pi*radius*radius
print("Area of circle is:",area)
elif choice == 2:
length = int(input("Enter the length of the Rectangle:-"))
Breath = int(input("Enter the breath of the Rectangle:-"))
area = length*Breath
print("Area of Rectangle:-", area)
elif choice == 3:
base = int(input("Enter the base of the triangle:-"))
height = int(input("Enter the height of the triangle:-"))
area = 0.5*base*height
print("Area of triangle:-", area)
elif choice == 4:
side = int(input("Enter the side of square:-"))
area = side*side
print("Area of side of square:-", area)
elif choice == 5:
a = float(input("Enter the first base:-"))
b = float(input("Enter the second base:-"))
height = float(input("Enter the height:-"))
area = ((a+b)/2)*height
print("Area of trapezoid:-", area)
elif choice == 6:
base = int(input("Enter the base of the parallelogram:-"))
height = int(input("Enter the height of the parallelogram:-"))
area = base*height
print("Area of parallelogram:-", area)
else:
print("wrong input!!")
OUTPUT:
Find area of following Shapes
1. Circle
2. Rectangle
3. Triangle
4. Square
5. Trapezoid
6. Parallelogram

Enter the choice:-1


Enter the radius of circle->20
Area of circle is: 1256.6370614359173

Enter the choice:-2


Enter the length of the Rectangle:-20
Enter the breath of the Rectangle:-30
Area of Rectangle:- 600

Enter the choice:-3


Enter the base of the triangle:-15
Enter the height of the triangle:-20
Area of triangle:- 150.0

Enter the choice:-4


Enter the side of square:-40
Area of side of square:- 1600

Enter the choice:-5


Enter the first base:-20
Enter the second base:-30
Enter the height:-40
Area of trapezoid:- 1000.0

Enter the choice:-6


Enter the base of the parallelogram:-40
Enter the height of the parallelogram:-50
Area of parallelogram:- 2000
Practical -3
3. Compute volume of following 3D shapes: cube, cylinder, cone and sphere.

print("Find volume of following 3D Shapes")


print('''1. Cube
2. Cylinder
3. Cone
4. Sphere''')
choice = int(input("Enter the choice:-"))

if choice == 1:
side = int(input("Enter the one side of cube:-"))
vol_cube = side**3
print("Volume of cube:-", vol_cube)
elif choice == 2:
from math import pi
radius = float(input("Enter the radius of cylinder->"))
height = float(input("Enter the height of cylinder->"))
vol_cylind = pi*radius*radius*height
print("Volume of cylinder is:",vol_cylind)
elif choice == 3:
from math import pi
radius = float(input("Enter the radius of cone->"))
height = float(input("Enter the height of cone->"))
vol_cone = 1/3*pi*radius*radius*height
print("Volume of cone:-", vol_cone)
elif choice == 4:
from math import pi
radius = float(input("Enter the radius of sphere->"))
vol_sphere = 4/3*pi*radius*radius*radius
print("Volume of sphere:-", vol_sphere)
else:
print("wrong input!!")

OUTPUT:

Find volume of following 3D Shapes


1. Cube
2. Cylinder
3. Cone
4. Sphere

Enter the choice:-1


Enter the one side of cube:-30
Volume of cube:- 27000

Enter the choice:-2


Enter the radius of cylinder->25
Enter the height of cylinder->60
Volume of cylinder is: 117809.72450961724

Enter the choice:-3


Enter the radius of cone->15
Enter the height of cone->40
Volume of cone:- 9424.777960769377

Enter the choice:-4


Enter the radius of sphere->30
Volume of sphere:- 113097.33552923254
Practical -4
4. Compute and print root of quadratic equation ax2+bx+c=0, where the values
of a, b and c are input by the user.

#import complex math module


importcmath
a=int(input("Enter a:"))
b=int(input("Enter b:"))
c=int(input("Enter c:"))
d=(b**2)-(4*a*c)
# find two results
ans1=(-b-cmath.sqrt(d)/(2*a))
ans2=(-b+cmath.sqrt(d)/(2*a))
#printing the results
print('the solution are {0} and {1}'.format(ans1,ans2))

OUTPUT:
Enter a:1
Enter b:5
Enter c:6
the solution are (-5.5+0j) and (-4.5+0j)
Practical -5
5. Print numbers up to N which are not divisible by 3,6,9,, e.g. 1,2,4,5.

Lower =int(input("Enter the lower range limit:-"))


Upper =int(input("Enter the upper range limit:-"))

fori in range(lower,upper+1):
if((i%3!=0)&(i%6!=0)&(i%9!=0)):
print(i)

OUTPUT:

Enter the lower range limit:-0


Enter the upper range limit:-16
1
2
4
5
7
8
10
11
13
14
16
Practical -6
6.write program to determine whether a triangle is isosceles or not?
def CheckTriangle(a,b,c):
if a==b or b==c or c==a:
print("the triangle is isosceles triangle.")
else:
print("The triangle is isosceles triangle.")
a=int(input("enter the one side of triangle:"))
b=int(input("ener the second side of triangle:"))
c=int(input("enter the third side of triangle:"))
CheckTriangle(a,b,c)
OUTPUT:
enter the one side of triangle:10
ener the second side of triangle:20
enter the third side of triangle:10
the triangle is isosceles triangle.
Practical -7
7. print multiplication table of a number input by the user

#Firstly we have to take a number from the user


numb =int(input("enter the numb which you get a multiplication table:-"))
print("the multiplication table of", numb)
#Using for loop
fori in range(1,11):
print(numb, "X", i,"=",numb*i)

# Using while loop


count=1
while count <=10:
numb=numb*1
print(numb, "X", count,"=",numb*count)
count+=1
OUTPUT:
enter the numb which you get a multiplication table:-5
the multiplication table of 5
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
5 X 8 = 40
5 X 9 = 45
5 X 10 = 50
Practical -8
8. Compute sum of natural numbers from one to n number.

num=int(input("Enter the number:-"))


ifnum<0:
print("Enter a positive number:-")
else:
sum=0
# use while loop to iterate until zero
while(num>0):
sum+=num
num-=1
print("The sum is", sum)
OUTPUT:
Enter the number:-3
The sum is 6
Practical -9
9. Print Fibonacci Series up to n numbers e.g. 0112358

#Firstly we have to take a numb variable


numb=int(input("Enter the number:-"))
n1,n2 =0,1
count =0
if numb<=1:
print("Enter the positive number")
elif numb ==1:
print("fibonnaci series up to",numb)
print(n1)
else:
print("fibonnaci series:-")
while count< numb:
print(n1)
nth=n1+n2
n1=n2
n2=nth
count+=1

OUTPUT:
Enter the number:-6
fibonnaci series:-
0
1
1
2
3
5
Practical -10
10. Compute factorial of a given number

num=int(input("Enter a number:"))
Factorial =1
ifnum<0:
print("Sorry, factorial does not exist for negative number")
elifnum==1:
print("The factorial of 0 is 1")
else:
fori in range(1,num+1):
Factorial=Factorial*i
print("the factorial of", num,"is",Factorial)
OUTPUT:
Enter a number:8
the factorial of 8 is 40320
Practical -11
11. Count occurrence of a digit 5 in a given integer number input by the user
num=input("Enter Integer:")

d=input("Enter Digit:")

d=num.count(d)

print(f"Count occurrence is:{d}")

Output:

Enter Integer:78547585335

Enter Digit:5

Count occurrence is:4


Practical -12
12. Print Geometric and Harmonic means of a series input by the user.

import math
def compute(a,b):
AM =(a+b)/2
print("Arithmatic mean=",AM)
GM= math.sqrt(a*b)
print("Geometric mean=",GM)
HM=(GM*GM)/AM
return HM
a=eval(input("enter the first number:"))
b=eval(input("enter the second number:"))
HM = compute(a, b)
print("Harmonic mean:",HM)
OUTPUT:
enter the first number:6
enter the second number:9
Arthmatic mean= 7.5
Geometric mean= 7.3484692283495345
Harmonic mean: 7.2
Practical -13
13. Evaluate the following expressions:
'''a. x-x2/2!+x3/3!- x4/4!+… xn/n!
b. x-x3/3!+x5/5!- x7/7!+… xn/n!'''

def fact(m):

if m==0:

return 1

else:

return m*fact(m-1)

s=0

x=int(input("Enter X :"))

n=int(input("Enter n:"))

fori in range(1,n+1):

s=s+((-1)**(i+1)*(x**i)/fact(i))

print("Sum of the Series:",round(s,3))

Output:

Enter X :2

Enter n:3

Sum of the Series: 1.333

>
b)

def fact(m):

if m==0:

return 1

else:

return m*fact(m-1)

s=0

x=int(input("Enter X :"))

n=int(input("Enter n:"))

fori in range(1,n+1):

k=(2*i)-1

s=s+((-1)**(i+1)*(x**k)/fact(k))

print("Sum of the Series:",round(s,3))

Output:

Enter X :2

Enter n:3

Sum of the Series: 0.933

>
Practical -14
14. Print all possible combinations of 4, 5, and 6.
fromitertools import combinations

a=int(input("Enter Ist Number:"))

b=int(input("Enter 2nd Number:"))

c=int(input("Enter 3rd Number:"))

for n in range(1,4):

A=combinations([a,b,c],n)

fori in A:

print(i)

OR

importitertools as IT

a=int(input("Enter Ist Number:"))

b=int(input("Enter 2nd Number:"))

c=int(input("Enter 3rd Number:"))

for n in range(1,4):

A=IT.combinations([a,b,c],n)

fori in A:

print(i)

Output:
Enter Ist Number:3

Enter 2nd Number:4

Enter 3rd Number:5

(3,)

(4,)

(5,)

(3, 4)

(3, 5)

(4, 5)

(3, 4, 5)

>
Practical-15

15. Determine prime numbers within a specific range.


m=int(input("Enter initial value:"))

n=int(input("Enter terminating value:"))

if m<n:

fori in range(m,n+1):

ifi>1:

for j in range(2,i):

ifi%j==0:

break

else:

print(i)

elif m>n:

fori in range(m,n,-1):

ifi>1:

for j in range(2,i):

ifi%j==0:

break

else:

print(i)

else:

print("Both the values are equal")

print("Enter different value")

OUTPUT:
Enter initial value:5

Enter terminating value:16

11

13

>

Enter initial value:17

Enter terminating value:5

17

13

11

>

Enter initial value:8

Enter terminating value:8

Both the values are equal

Enter different value

>

Practical-16
16.Count number of persons of age above 60 and below 90.
n=int(input("No. of Persons :"))

print("Enter ages of",n,"persons")

A=[]

fori in range(n):

A.append(int(input()))

print("Ages:")

fori in range(n):

if A[i]<=0:

print("NA")

elif A[i]>=110:

print("AGE?")

else:

print(A[i])

c=0

fori in A:

ifi>60 and i<=90:

c=c+1

print("Persons between 60 & 90 are:")

print(c)

OUTPUT:
No. of Persons :6

Enter ages of 6 persons

34

68

87

79

119

Ages:

34

NA

68

87

79

AGE?

Persons between 60 & 90 are:

>
PRACTICAL-17
17. Compute transpose of a matrix.

R=int(input("Enter Rows:"))
C=int(input("Enter Columns:"))

print("Enter Elements: ")


A=[]
fori in range(R):
B=[]
for j in range(C):
B.append(int(input()))
A.append(B)

print("The Matrix is:")


fori in range(R):
for j in range(C):
print(A[i][j],end=' ')
print()

print("The Transpose of Matrix is:")


fori in range(C):
for j in range(R):
print(A[j][i],end=' ')
print()

OUTPUT:
Enter Rows:
2
Enter Columns:
3
Enter Elements:
2
3
4
5
6
7
The Matrix is:
234
567
The Transpose of Matrix is:
25
36
47

PRACTICAL-18
18. Perform following operations on two matrices.1) Addition 2)
Subtraction 3) Multiplication

R1=int(input("Enter Rows for 1st Matrix:"))


C1=int(input("Enter Columns for 1st Matrix:"))
print("Enter Elements: ")
M1=[]
fori in range(R1):
A=[]
for j in range(C1):
A.append(int(input()))
M1.append(A)
print("First Matrix is:")
fori in range(R1):
for j in range(C1):
print(M1[i][j],end=' ')
print()
R2=int(input("Enter Rows for 2nd Matrix:"))
C2=int(input("Enter Columns for 2nd Matrix:"))
print("Enter Elements: ")
M2=[]
for p in range(R2):
B=[]
for q in range(C2):
B.append(int(input()))
M2.append(B)
print("Second Matrix is:")
for p in range(R2):
for q in range(C2):
print(M2[p][q],end=' ')
print()
''' Addition and Subtraction of two matrices'''
if R1==R2 and C1==C2:
print("Addition of two matrices is :")
for m in range(R1):
for n in range(C1):
print(M1[m][n] + M2[m][n],end=' ')
print()
print("Subtraction of two matrices is :")
for m in range(R1):
for n in range(C1):
print(M1[m][n] - M2[m][n],end=' ')
print()
else:
print("Addition and Subtraction is not possible")
''' Product of two matrices'''
M3=[[0,0],[0,0]]
if C1==R2:
print("Multiplication of two matrices is :")
for m in range(R1):
for n in range(C2):
for k in range(C1):
M3[m][n]+=M1[m][k]*M2[k][n]
for l in M3:
print(l)
else:
print("Multiplication is not possible")

OUTPUT:

Enter Rows for 1st Matrix:


2
Enter Columns for 1st Matrix:
2
Enter Elements:
7
5
4
8
First Matrix is:
75
48
Enter Rows for 2nd Matrix:
2
Enter Columns for 2nd Matrix:
2
Enter Elements:
5
1
2
5
Second Matrix is:
51
25
Addition of two matrices is :
12 6
6 13
Subtraction of two matrices is :
24
23
Multiplication of two matrices is :
[45, 32]
[36, 44]

PRACTICAL-19
19. Count occurrence of vowels.

STR=str(input("Enter any String"))


STR=STR.lower()
c={}
SEARCH="aeiou"
fori in SEARCH:
n=STR.count(i)
c[i]=n
print("Occurrence of Vowels in string")
print(c)

OUTPUT:
Enter any String
ILiveInIndia
Occurrence of Vowels in string
{'a': 1, 'e': 1, 'i': 5, 'o': 0, 'u': 0}

PRACTICAL:20
20. Count the total number of vowels in a word.

STR=str(input("Enter any String"))


STR=STR.lower()
c={}
SEARCH="aeiou"
fori in SEARCH:
n=STR.count(i)
c[i]=n
print("Occurrence of Vowels in string:")
print(c)
m=c.values()
TC=sum(m)
print("Total No. of Vowels are:")
print(TC)

OUTPUT:
Enter any String
ILiveInIndia
Occurrence of Vowels in string:
{'a': 1, 'e': 1, 'i': 5, 'o': 0, 'u': 0}
Total No. of Vowels are:
7

PRACTICAL-21
21. Determine whether a string is palindrome or not.

STR=str(input("Enter any String"))


print("Entered String is:",STR)
REV=STR[::-1]
print("Reverse of a string is:",REV)
if STR==REV:
print("Entered String is Palindrome")
else:
print("Entered String is not Palindrome")

OUTPUT:
Enter any String
madam
Entered String is: madam
Reverse of a string is: madam
Entered String is Palindrome

Practical-22
Perform following operations on a list of numbers:
1) Insert an element 2) delete an element 3) sort the list 4) delete entire
list

n=int(input("Enter how many elements you want in a list:"))


if n>0:
print("Enter",n,"elements")
LIST=[]
fori in range(n):
LIST.append(int(input("Enter Element")))
print("LIST IS",LIST)
a=int(input("Enter element to insert in a list:"))
b=int(input("Enter Index position at which u want to insert an element"))
LIST.insert(b,a)
print("List after inserting new element at index",b)
print(LIST)
c=int(input("Enter elememt you want to delete from list"))
LIST.remove(c)
print("List after deletion:")
print(LIST)
LIST.sort()
print("Sorted list is:")
print(LIST)
LIST.clear()
print("Deleting the entire list")
print(LIST)
else:
print("Kindly re-enter the value for n")

OUTPUT:
Enter how many elements you want in a list:
4
Enter 4 elements
Enter Element
23
Enter Element
67
Enter Element
45
Enter Element
12
LIST IS [23, 67, 45, 12]
Enter element to insert in a list:
87
Enter Index position at which u want to insert an element
2
List after inserting new element at index 2
[23, 67, 87, 45, 12]
Enter element you want to delete from list
67
List after deletion:
[23, 87, 45, 12]
Sorted list is:
[12, 23, 45, 87]
Deleting the entire list
[]

Practical-23
23. Display word after Sorting in alphabetical order.

STR=str(input("Enter any String"))


print("Entered string is:")
print(STR)
print("Sorted list is:")
STR=sorted(STR)
print(STR)
STR1=""
print("String in Sorted form is:")
print(STR1.join(STR))

OUTPUT:1

Enter any String


students
Entered string is:
students
Sorted list is:
['d', 'e', 'n', 's', 's', 't', 't', 'u']
String in Sorted form is:
denssttu

OUTPUT:2
Enter any String
welcome to python
Entered string is:
welcome to python
Sorted list is:
[' ', ' ', 'c', 'e', 'e', 'h', 'l', 'm', 'n', 'o', 'o', 'o', 'p', 't', 't', 'w', 'y']
String in Sorted form is:
ceehlmnooopttwy

PRACTICAL-24
24. Perform sequential search on a list of given numbers.

def FUN(LIST,key):
fori in range(len(LIST)):
if LIST[i]==key:
returni
break
return -1
LIST=[2,4,5,1,7,3]
print("The List is:",LIST)
key=int(input("The No. you want to search"))
n=FUN(LIST,key)
if n !=-1:
print(key,"is found at position ",n+1)
else:
print("Data not found")

Output:1
The List is: [2, 4, 5, 1, 7, 3]
The No. you want to search
4
4 is found at position 2

Output 2:
The List is: [2, 4, 5, 1, 7, 3]
The No. you want to search
8
Data not found

Practical -25
25. Perform sequential search on ordered list of given numbers.

defSequential_Search(list, item):
pos = 0
found = False
whilepos<len(list) and not found:
if list[pos] == item:
found = True
else:
pos = pos + 1
return found, pos
ele_list=[]
n=int(input("enter the number of elements:-"))
fori in range(0,n):
element=int(input())
ele_list.append(element)
item=int(input("enter the number to search:-"))
print("here is our list:-",ele_list)
print("here we are searching element present or not",Sequential_Search(ele_list,
item))
OUTPUT:
enter the number of elements:-5
2
3
4
5
6
enter the number to search:-3
here is our list:- [2, 3, 4, 5, 6]
here we are searching element present or not (True, 1)

Practical -26
26. Maintain practical note book as per their serial numbers in library using Python
dictionary

from collections import OrderedDict


D1={}
D1[5]="Print numbers up to N which are not divisible by 3, 6, 9,, e.g., 1, 2, 4, 5, 7,
…."
D1[6]="Write a program to determine whether a triangle is isosceles or not?"
D1[1]="Compute sum, subtraction, multiplication, division and exponent of given
variables input by the user"
D1[3]="Compute volume of following 3D shapes: cube, cylinder, cone and sphere."
D1[2]="Compute area of following shapes: circle, rectangle, triangle, square,
trapezoid and parallelogram"
D1[4]="compute and print root of quadratic equation ax2+bx+c=0, where the values
of a,b and c are input by the user"
D=OrderedDict(sorted(D1.items()))
fori, j in D.item():
print("Program number",i,":-",j)
OUTPUT:
Program number 1:- Compute sum, subtraction, multiplication, division
and exponent of given variables input by the user
Program number 2:- Compute area of following shapes: circle,
rectangle, triangle, square, trapezoid and parallelogram
Program number 3:- Compute volume of following 3D shapes: cube,
cylinder, cone and sphere.
Program number 4:- compute and print root of quadratic equation
ax2+bx+c=0, where the values of a,b and c are input by the user
Program number 5:- Print numbers up to N which are not divisible by
3, 6, 9,, e.g., 1, 2, 4, 5, 7,….
Program number 6:- Write a program to determine whether a triangle is
isosceles or not?"

Practical -27
27. Perform following operations on dictionary 1) Insert 2) delete 3) change

my_dict = {1: 'apple', 2: 'ball',3: 'car'}


print(my_dict)
my_dict[4] = 'Dragonfruit'
print("after insertion:-", my_dict)
my_dict.pop(4)
print("after deletion:-", my_dict)
my_dict[2] = "banana"
print("after change:-", my_dict)
OUTPUT:
{1: 'apple', 2: 'ball', 3: 'car'}
after insertion:- {1: 'apple', 2: 'ball', 3: 'car', 4: 'Dragonfruit'}
after deletion:- {1: 'apple', 2: 'ball', 3: 'car'}
after change:- {1: 'apple', 2: 'banana', 3: 'car'}

Practical -28
28. Check whether a number is in a given range using functions

defcheck_range(n):
if n in range(10,20):
print( "Number",n,"is in the range")
else :
print("The number is outside the given range.")
n=int(input("enter number"))
check_range(n)
OUTPUT:
enter number15
Number 15 is in the range

Practical -29
29. Write a Python function that accepts a string and calculates number of upper
case letters and lower case letters available in that string.

defstring_test(s):
UPPER_CASE = 0
LOWER_CASE = 0
for c in s:
ifc.isupper():
UPPER_CASE += 1
elifc.islower ():
LOWER_CASE += 1
else:
pass
print ("No. of Uppercase characters : ", UPPER_CASE)
print ("No. of Lowercase characters : ", LOWER_CASE)
s = input ("Enter sentence :- ")
string_test(s)
OUTPUT:
Enter sentence :-PythonProgramminG
No. of Uppercase characters : 3
No. of Lowercase characters : 14

Practical -30
30. To find the Max of three numbers using functions.

def maximum(a, b, c):


if (a >= b) and (a >= c):
largest = a
elif (b >= a) and (b >= c):
largest = b
else:
largest = c
return largest
Max = maximum(2, 4, 7)
print("Largest Number: ", Max)
OUTPUT:
Largest Number: 7

Practical -31
31 Multiply all the numbers in a list using functions.
defmul_list(list) :
# Multiply elements one by one
product = 1
fori in list:
product = product * i
return product
list1 = [11, 12, 4, 3]
print(list1)
print("product: ")
print(mul_list(list1))
OUTPUT:
[11, 12, 4, 3]
product:
1584

Practical -32
32. Solve the Fibonacci sequence using recursion.

defrecur_fibo(n):
if n <= 1:
return n
else:
return(recur_fibo(n-1) + recur_fibo(n-2))
nterms = 10
# check if the number of terms is valid
ifnterms<= 0:
print("Plese enter a positive integer")
else:
print("Fibonacci sequence:")
fori in range(nterms):
print(recur_fibo(i))
OUTPUT:
Fibonacci sequence:
0
1
1
2
3
5
8
13
21
34

Practical -33
33. Get the factorial of a non-negative integer using recursion.

defrecur_factorial(n):
if n == 1:
return n
else:
return n*recur_factorial(n-1)
num = 7
# check if the number is negative
ifnum< 0:
print("Sorry, factorial does not exist for negative numbers")
elifnum == 0:
print("The factorial of 0 is 1")
else:
print("The factorial of", num, "is", recur_factorial(num))
OUTPUT:
The factorial of 7 is 5040

Practical -34
34. Write a program to create a module of factorial in Python.
Firstly, we have to create a module file name “factorial.py” same as python file extension.

Then we have to create a main file named as “main.py”: -

OUTPUT:
Enter the number: -8

The factorial of 8 is 40320

Practical -35
35. Design a Python class named Rectangle, constructed by a length &width,
also design a method which will compute the area of a rectangle.
class Rectangle:
def __init__(self, length, width):
self.length = length
self.width = width
def area(self):
returnself.length * self.width
a = int(input("Enter the length: - "))
b = int(input("Enter the width: - "))
obj = Rectangle(a, b)
print("Area of rectangle is: ", obj.area())
OUTPUT:
Enter the length: - 40
Enter the width: - 30
Area of rectangle is: 1200

Practical -36
36 Design a Python class named Circle constructed by a radius and two methods
which will compute the area and the perimeter of a circle.
class Circle():
def __init__(self, radius):
self.radius = radius
def area(self):
return 3.14 * self.radius ** 2
def perimeter(self):
return 2 * 3.14 * self.radius
radius = int(input("Enter the radius: - "))
obj = Circle(radius)
print("Area of circle is: ", obj.area())
print("Perimeter of circle is: ", obj.perimeter())
OUTPUT:
Enter the radius: - 50
Area of circle is: 7850.0
Perimeter of circle is: 314.0

Practical -37
37. Design a Python class to reverse a string ‘word by word’.
classReverseString:
def __init__(self, string):
self.string = string
defreverse_string(self):
return " ".join(self.string.split()[::-1])
string = input("Enter a string: ")
reverse_string = ReverseString(string)
print("The result is: ", reverse_string.reverse_string())
OUTPUT:
Enter a string: word by word
The result is: word by word

Practical -38
38. Write a Python program to read an entire text file.
Firstly, we have to create a simple text file “sample.txt”: -

Now we have to create a main file named as “main.py”: -

Main file code: -

OUTPUT:

Practical -39
39. Design a Python program to read first n lines of a text file.
Firstly, we have to create a simple text file “sample.txt”: -

Now we have to create a main file named as “main.py”: -

Main file code: -

OUTPUT:

Practical -40
40. Construct a Python program to write and append text to a file and display
the Text
my_file = open("sample.txt", "w")
# here we have write in a file and we can write multiple lines
n = int(input("How many user name you can enter: - "))
fori in range(0, n):
user_name = input("Enter user name: - ")
user_age = input("Enter user classA: - ")
user_token = input("Enter user ClassB: - ")
my_file.write(user_name + "\n")
my_file.write(user_age + "\n")
my_file.write(user_token + "\n")
# herei am using apped method to append text in a file
my_file = open("sample.txt", "a")
append_text = input("Enter the text you want to append: - ")
my_file.write(append_text + "\n")
# herei am using read method to read text from a file
my_file = open("sample.txt", "r")
print("Here is the informatioin which we read from a file: -")
lines = my_file.read()
print(lines)
my_file.close()
OUTPUT:
How many user name you can enter: - 2
Enter user name: - python
Enter user classA: - BCA
Enter user ClassB: - Cyber
Enter user name: - python lab
Enter user classA: - BCA
Enter user ClassB: - Cyber
Enter the text you want to append: - All the best to all
Here is the informatioin which we read from a file: -
python lab
BCA
Cyber
All the best to all

SAMPLE VIVA QUESTIONS


Q1: Name the key features of Python?

Q2: How to check if all characters in a string are alphanumeric?

Q3: Name the built-in types available in Python?

Q4: Explain the difference between a list and a tuple?

Q5: What is the use of %s in python?

Q6: What is a pass in Python?

Q7: How are files deleted in Python?

Q8: What is pep 8?

Q9: What is [::-1} used for?

Q10: What is Numpy?

Q11: What is Scipy?

Q12: Explain how to delete a file in Python?

Q14: What is slicing?

Q15: How do you reverse a list?


Q16: What is a Python module, and how are they used?

Q17:What is the use of "init" method in python?

Q18: Can you explain about "self" keyword in python?

Q19: How to use exception handling in python?

Q20:What is the use of lambda functions in python?

You might also like