0% found this document useful (0 votes)
13 views5 pages

2023-24-Part-1-Python-Lab Manual python-DVD

The document describes a program to find the length of a list using recursion. It defines a Recur method that takes a list as a parameter and returns the length by incrementing a counter each time the method calls itself on the remaining part of the list. It also asks some review questions related to recursion, slicing, indexing, and returning values from functions.

Uploaded by

adesh.k4139
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)
13 views5 pages

2023-24-Part-1-Python-Lab Manual python-DVD

The document describes a program to find the length of a list using recursion. It defines a Recur method that takes a list as a parameter and returns the length by incrementing a counter each time the method calls itself on the remaining part of the list. It also asks some review questions related to recursion, slicing, indexing, and returning values from functions.

Uploaded by

adesh.k4139
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
You are on page 1/ 5

NUTAN MAHARASHTRA VIDYA PRASARAK MANDAL’S

NUTAN COLLEGE OF ENGINEERING & RESEARCH (NCER)


Department of Computer Science & Engineering (CSE)
---------------------------------------------------------------------------------------------------------------------

Experiment No - 10

Program to find the length of a list using recursion.

Problem Description: When it is required to find the length of a list with the help
of recursion technique, a user defined method is used, and simple indexing
technique is used.

Problem Solution:
 method named ‘Recur’ is defined, that takes a list as a parameter.
 If the list is not present, the method returns 0.
 Otherwise, it is indexed, and incremented by 1 and returned as output.
 It will ask to enter a list
 List will be splited by using ‘split’ function
 Outside the function, a list is defined, and is displayed on the console.
 The method is called by passing this list as a parameter.
 The output is then displayed on the console.

Practical Related Question

1. What is Recursion?

2. What is Slicing?

3. What is Indexing?

4. If we are not writing any return in the given function then while printing the
function what will be the corresponding output

BTCOL406 : Python Programming Prof. Dhammjyoti Dhawase


NUTAN MAHARASHTRA VIDYA PRASARAK MANDAL’S
NUTAN COLLEGE OF ENGINEERING & RESEARCH (NCER)
Department of Computer Science & Engineering (CSE)
---------------------------------------------------------------------------------------------------------------------

BTCOL406 : Python Programming Prof. Dhammjyoti Dhawase


NUTAN MAHARASHTRA VIDYA PRASARAK MANDAL’S
NUTAN COLLEGE OF ENGINEERING & RESEARCH (NCER)
Department of Computer Science & Engineering (CSE)
---------------------------------------------------------------------------------------------------------------------

Experiment No - 11

compute the diameter, circumference, and volume of a sphere using class

Problem Description: sphere is a perfectly round geometrical object in 3-


dimensional space. It is the set of all the points located a particular distance away
from a particular point called center. It is perfectly symmetrical and has no edges or
vertices.

Problem Solution:
1. Define the radius of the sphere
2. Define the pie and assign (22/7)
3. Calculate the volume of the sphere as (4/3)*pie*r3
4. Assign the volume of the sphere to volume_of_sphere
5. Print the volume of the sphere.

Practical Related Questions

1. How to declare classes and objects in python

2. What is self in __init__ () function

3. What is __init__() and __str__() .Explain in detail

BTCOL406 : Python Programming Prof. Dhammjyoti Dhawase


NUTAN MAHARASHTRA VIDYA PRASARAK MANDAL’S
NUTAN COLLEGE OF ENGINEERING & RESEARCH (NCER)
Department of Computer Science & Engineering (CSE)
---------------------------------------------------------------------------------------------------------------------

Experiment No – 11

Write a program to compute the diameter and volume of a sphere using


class

Program:
class sphere:
def _init_(self):
print("object created")
obj=sphere()
radius=float(input("Enter Radius= "))
pi=3.14

diameter=2*radius
print("Diameter is= ",diameter)

volume=4/3*pi*radius*radius*radius
print("volume is=",volume)

Output:

object created
Enter Radius= 5
Diameter is= 10
volume is= 523.3333333333334

BTCOL406 : Python Programming Prof. Dhammjyoti Dhawase


NUTAN MAHARASHTRA VIDYA PRASARAK MANDAL’S
NUTAN COLLEGE OF ENGINEERING & RESEARCH (NCER)
Department of Computer Science & Engineering (CSE)
---------------------------------------------------------------------------------------------------------------------

Experiment No - 12
Program to read a file and capitalize the first letter of every word in
the file.

Problem Description
The program reads a file and capitalizes the first letter of every word in
the file.

Problem Solution
1. Take the file name from the user.
2. Read each line from the file and use the title() function to capitalize
each word in the line.
3. Print the altered lines of the file.
5. Exit.

Practical Related Questions

1. How to read and write file in python


2. What are the different file operations present in python
3. Explain any 10 inbuilt functions in python

BTCOL406 : Python Programming Prof. Dhammjyoti Dhawase

You might also like