You are on page 1of 3

1.

Given a list of words, find all pairs of unique indices such that the concatenation of the two
words is a palindrome.

For example, given the list ["code", "edoc", "da", "d"], return [(0, 1), (1, 0), (2, 3)].

2. Implement a 2D iterator class. It will be initialized with an array of arrays, and should
implement the following methods:

● next(): returns the next element in the array of arrays. If there are no more elements,
raise an exception.
● has_next(): returns whether or not the iterator still has elements left.

For example, given the input [[1, 2], [3], [], [4, 5, 6]], calling next() repeatedly should output 1, 2,
3, 4, 5, 6.

3. Given an array of integers, return a new array where each element in the new array is the
number of smaller elements to the right of that element in the original input array.

For example, given the array [3, 4, 9, 6, 1], return [1, 1, 2, 1, 0], since:

● There is 1 smaller element to the right of 3


● There is 1 smaller element to the right of 4
● There are 2 smaller elements to the right of 9
● There is 1 smaller element to the right of 6
● There are no smaller elements to the right of 1

4. Write a Rectangle class allowing you to build a rectangle with length and width
attributes.Create a Perimeter() method to calculate the perimeter of the rectangle
and a Area() method to calculate the area of ​the rectangle.Create a method display()
that display the length, width, perimeter and area of an object created using an
instantiation on rectangle class.Create a Parallelepipede child class inheriting from
the Rectangle class and with a height attribute and another Volume() method to
calculate the volume of the Parallelepiped.In the main function, make 10 objects of
Parallelepipede class and then display it on the screen as well as write its data in text
file in the following format:
Object No: 1

Height: ?

Length: ?

Width: ?

Area: ?

Volume:?

5.Create a Python class Person with attributes: name and age of type
string.Create a display() method that displays the name and age of an object
created via the Person class.Create a child class Student which inherits from
the Person class and which also has a section attribute.Create a method
displayStudent() that displays the name, age and section of an object
created via the Student class.Create a student object via an instantiation on
the Student class and then test the displayStudent method.You are provided
with “Person.csv” file.You have to read that file and take arguments name, age
and section from that file.

6.Create a Computation class with a default constructor (without


parameters) allowing to perform various calculations on integers
numbers.Create a method called Factorial() which allows to calculate the
factorial of an integer. Test the method by instantiating the class. Create a
method called Sum() allowing to calculate the sum of the first n integers 1 + 2
+ 3 + .. + n. Test this method.Create a method called testPrim() in the
Calculation class to test the primality of a given integer. Test this method.
Create a method called testPrims() allowing to test if two numbers are prime
between them. Create a tableMult() method which creates and displays the
multiplication table of a given integer upto 10.
7.Create class Patient with data members, patient ID, name, age, blood
group.Create child class of Patient named PatientType with additional data
member type of patient whether he is admitted to hospital or OPD patient.
Define proper methods or member functions in each class and str
functions.In the main, make 100 objects of patient_type class and store them
in a list.Write data of all the objects in text file in proper format.

You might also like