0% found this document useful (0 votes)
2 views19 pages

Python Lab Manual - Sample

The document outlines a Python lab manual with various programming exercises. It includes tasks such as reading student details, generating Fibonacci sequences, calculating factorials, and processing text files. Each exercise specifies the expected output and hints for implementation.

Uploaded by

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

Python Lab Manual - Sample

The document outlines a Python lab manual with various programming exercises. It includes tasks such as reading student details, generating Fibonacci sequences, calculating factorials, and processing text files. Each exercise specifies the expected output and hints for implementation.

Uploaded by

nagannavedanth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Python Lab Manual

1. a. Develop a program to read the student details like Name, USN, and Marks in three
subjects. Display the student details, total marks and percentage with suitable
messages.

OUTPUT
1 b. Develop a program to read the name and year of birth of a person. Display whether
the person is a senior citizen or not.

OUTPUT:

1.

2.

3.

2. a. Develop a program to generate Fibonacci sequences of length (N). Read N from the console.
OUTPUT:

2. b. Write a function to calculate the factorial of a number. Develop a program to compute


binomial coefficient (Given N and R).
OUTPUT:

3. Read N numbers from the console and create a list. Develop a program to print mean, variance
and standard deviation with suitable messages.
OUTPUT
4. Read a multi-digit number (as chars) from the console. Develop a program to print the
frequency of each digit with a suitable message.

OUTPUT
5. Develop a program to print 10 most frequently appearing words in a text file. [Hint: Use a
dictionary.

lab5.py

words.txt
OUTPUT

6. Develop a program to sort the contents of a text file and write the sorted contents into a
separate text file. [Hint: Use string methods strip(), len(), list methods sort(), append(), and file
methods open(), readlines(), and write()].
words.txt

sorted_words.txt
OUTPUT:
7. Develop a program to backing Up a given Folder (Folder in a current working directory) into a
ZIP File by using relevant modules and suitable methods.
OUTPUT:

A folder should be created in the current working directory for which the backup needs to be done. After
running the program the ZIP File will be created for the respective folder.

8. Write a function named DivExp which takes TWO parameters a, b and returns a value c (c=a/b).
Write a suitable assertion for a>0 in function DivExp and raise an exception for when b=0. Develop
a suitable program which reads two values from the console and calls a function DivExp.
OUTPUT 1

OUTPUT 2

9. Define a function which takes TWO objects representing complex numbers and returns new
complex number with a addition of two complex numbers. Define a suitable class ‘Complex’ to
represent the complex number. Develop a program to read N (N >=2) complex numbers and to
compute the addition of N complex numbers.
.

OUTPUT:
10. Develop a program that uses class Student which prompts the user to enter marks in three
subjects and calculates total marks, percentage and displays the score card details. [Hint: Use list
to store the marks in three subjects and total marks. Use __init__() method to initialize name, USN
and the lists to store marks and total, Use getMarks() method to read marks into the list, and
display() method to display the score card details.]

OUTPUT:

You might also like