PP Lab Questions
PP Lab Questions
Set Number: 1
1. Write a function that takes a function and a list of numbers as arguments and applies the
function to each element in the list, returning a new list of results.
2. Write a Pandas program to select the rows where the number of attempts in the
examination is greater than 2.
3. Write a function that takes any number of arguments and returns their sum.
4. Python Program to Read a Text File and Print all the Numbers Present in the Text File
5. Write a Python program that reads a CSV file containing student information (name, age,
grade) and creates a new CSV file with only the names of students who have passed (grade
>= 60).
Set Number: 2
1. Design python code to illustrate the following plots using ‘matplotlib’ package:
- Bar plot - Histogram
2. Write a function that takes any number of arguments and returns their sum.
3. Implement python code to Zipping Files
4. Python Program to Read a Text File and Print all the Numbers Present in the Text File
5. Define a module named `geometry` that includes functions for calculating the area and
perimeter of various geometric shapes such as rectangles, circles, and triangles. Import the
module and demonstrate the use of each function with user input.
Set Number: 3
1. Develop a Python script that searches for a specific word in a text file. Print the line
numbers where the word is found.
2. Write a Pandas program to select the ‘name’ and ‘score’ columns from the DataFrame.
3. Create a Python script that reads a file and counts the number of lines in it. Print the line
count to the console.
4. Define a module named calculator that includes functions for addition, subtraction,
multiplication, and division. Import the module and demonstrate the use of each function
with user input.
5. Python Program to Read a Text File and Replace a Specific Word with Another Word.
Set Number: 4
1. Write a Pandas program to select the specified columns and rows from a given data frame.
2. Implement a function to find nth Fibonacci number.
3. Convert Fahrenheit to Celsius for a list of temperatures using Map
4. Implement python code to Concatenate Two Files
5. Implement a function that takes a list of tuples as input, where each tuple contains a
student's name and their exam scores, and returns a dictionary where the keys are the student
names and the values are their average scores.
Set Number: 5
1. Write a function that takes a list of numbers as arguments and returns their sum.
2. Write a Python program to demonstrate abstraction by creating an abstract class Animal
with an abstract method speak, and derived classes Dog and Cat implementing the speak
method differently.
3. Write a Python program to demonstrate class methods and static methods by creating a
class MathUtils with a class method add and a static method square.
4. Define a module named calculator that includes functions for addition, subtraction,
multiplication, and division. Import the module and demonstrate the use of each function
with user input.
5. Write a function that calculates the nth prime number.
Set Number: 6
1. Write a Pandas program to change the name ‘James’ to ‘Adhvik’ in name column of the
DataFrame.
2. Write a Python program to demonstrate property decorators by creating a class Person
with private attribute __age and a property age to access it.
3. Implement python code to Find the Longest Line in a File
4. Write a Python script that copies the contents of one text file ('source.txt') to another file
('destination.txt').
5. Define a module named `data_processing` that includes functions for reading data from
CSV files, performing data cleaning operations, and visualizing data using matplotlib. Import
the module and apply these functions to a sample dataset.
Set Number: 7
1. Write a function that takes a fixed number of positional arguments, followed by a variable
number of positional arguments, and prints them.
2. Write a Python program to demonstrate abstraction by creating an abstract class Animal
with an abstract method speak, and derived classes Dog and Cat implementing the speak
method differently.
3. Write a Python program to demonstrate method overriding by creating a base class Parent
with a method display, and a derived class Child overriding the display method.
4. Implement python code to Remove Duplicate Lines from a File
5. Write a Python program that reads an integer from a file named 'number.txt' and prints its
square root. Handle the `ZeroDivisionError` exception if the file contains the number 0.
Set Number: 8
1. Implement python code to Find the Longest Line in a File
2. Develop a python code to handle the following built-in exceptions i) ValueError ii)
ZeroDivisionError iii) TypeError iv) NameErrror
3. Write a Pandas program to change the name ‘James’ to ‘Adhvik’ in name column of the
DataFrame.
4. Implement python code to Read Specific Lines from a File
5. Create a program that reads a text file containing emails and phone numbers, extracts all
valid email addresses, and writes them to a new file.
Set Number: 9
1. Write a Python program to demonstrate polymorphism by creating a base class Shape with
a method draw and two derived classes Circle and Rectangle, each implementing the draw
method differently.
2. Implement python code to handle multiple exceptions.
3. Write a Python program to demonstrate abstraction by creating an abstract class Animal
with an abstract method speak, and derived classes Dog and Cat implementing the speak
method differently.
4. Implement python code to Concatenate Two Files
5. Develop a function that takes a string as input and returns True if it contains at least one
uppercase letter, one lowercase letter, one digit, and one special character, False otherwise.
Set Number: 10
1. Define a module named calculator that includes functions for addition, subtraction,
multiplication, and division. Import the module and demonstrate the use of each function
with user input.
2. Write a function that takes two arguments, with one having a default value. The function
should return the sum of the two arguments.
3. Convert Fahrenheit to Celsius for a list of temperatures using Map
4. Write a function that takes a string as input and returns a dictionary where the keys are
the unique words in the string and the values are the counts of each word
5. Write a function that calculates the nth prime number
Set Number: 11
1. Write a function that takes two arguments, with one having a default value. The function
should return the sum of the two arguments.
2. Write a Python program to demonstrate composition by creating classes Engine and Car,
where Car contains an instance of Engine.
3. Write a Python program to demonstrate multiple inheritance by creating classes A and B,
and a class C inheriting from both A and B.
4. Write a function that takes a fixed number of positional arguments, followed by a variable
number of positional arguments, and prints them.
5. Develop a program that reads a CSV file containing stock prices for multiple companies
and calculates the average price for each company over a specified time period.
Set Number: 12
1. Write a Python program to demonstrate method overriding by creating a base class Parent
with a method display, and a derived class Child overriding the display method.
2. Write a function that takes a function and a list of numbers as arguments and applies the
function to each element in the list, returning a new list of results.
3. Write a Python program to demonstrate encapsulation by creating a class BankAccount
with private attributes __balance and methods deposit and withdraw to update the balance.
4. Implement python code to Zipping Files
5. Write a function that takes a list of numbers as arguments and returns their sum.
Set Number: 13
1. Write a Python program to demonstrate polymorphism by creating a base class Shape with
a method draw and two derived classes Circle and Rectangle, each implementing the draw
method differently.
2. Write a function that takes any number of arguments and returns their sum.
3. Develop a program that reads a text file and counts the number of words in it. Display the
word count to the user.
4. Define a module named string_utilities that contains functions for reversing a string and
counting the occurrences of a specific character. Import the module and apply these functions
to a user-provided string.
5. Implement python code to Read Specific Lines from a CSV File.
Set Number: 14
1. Write a function that takes two arguments, with one having a default value. The function
should return the sum of the two arguments.
2. Create a Python script that reads a file and counts the number of lines in it. Print the line
count to the console.
3. Define a module named calculator that includes functions for addition, subtraction,
multiplication, and division. Import the module and demonstrate the use of each function
with user input.
4. Write a Pandas program to select the specified columns and rows from a given data
frame.
5. Implement python code to Unzipping Files.
Set Number: 15
1. Implement a function to find nth Fibonacci number.
2. Develop a python code to handle the following built-in exceptions i) ValueError ii)
ZeroDivisionError iii) TypeError iv) NameErrror
3. Implement python code to Write Data to a CSV File
4. Implement function to compute GCD, LCM of two numbers (use Lambda function)
5. Implement a function that takes a list of strings as input and returns a new list containing
only the strings that are palindromes. 5. Define a module named `data_processing` that
includes functions for reading data from CSV files, performing data cleaning operations, and
visualizing data using matplotlib. Import the module and apply these functions to a sample
dataset.