python index
python index
7 two sets.
8 Write a program that performs insertion sort over a list of
strings.
9 Write a program to input two lists, sort them and then
merge them into third list in a sorted manner.
Define a dictionary to store names of footballers along with
10 the number of goals they have scored in world cups. Sort
the dictionary is descending order of goals. Display the
footballer, who has scored the highest number of goals.
Write a program to accept two filenames as command line
11 arguments. Then copy the contents of one file into another
adding line number to each line. Incorporate validation
checks wherever applicable.
Write a program to input a list of integers, numlist[]. Then
find the HCF of the numlist[2] and numlist[8]. Incorporate
routines to handle any type of exceptions that may arise.
12
(Note: Common exceptions in this problem may be
NameError, ZeroDivisionError, IndexError, ValueError etc)
Define a class called MyPoint, which models a 2D point with
x and y coordinates. Include the following:
• A constructor that initializes a 2D point.
• A method setXY() to set both x and y.
• A method getXY() which returns the x and y in a list
13 A method to print a point using special member functions.
• A method to add two points.
• A method to compute the distance between this
point and another point passed as argument.
• A method to test whether two points are coincident
or not.
Write a program to implement the above.
Derive a class Point3D inherited from the class MyPoint in
14 problem 12. This class should model a 3D point with x, y
and z co-ordinates. Include all the functions in MyPoint
class to perform corresponding operations in a 3D point
15 Incorporate the concept of public, private and protected
data members in the above class.
Write a program to input two strings and print a new string
16 where the first string is reversed, and the second string is
converted to upper case.
Example- input: “pets“, “party”, output: “step PARTY”.
Write a program that initializes a list of words, and then join
17 all the words in the odd and even indices to form two
strings.
18 Write a program to simulate stack and queue using lists.