0% found this document useful (0 votes)
3 views

python index

The document outlines a series of programming assignments that require the implementation of various functions and classes in Python. Tasks include defining functions for prime numbers, matrix operations, and string manipulations, as well as creating classes for 2D and 3D points. Each assignment emphasizes the use of specific programming concepts such as lists, dictionaries, and exception handling.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

python index

The document outlines a series of programming assignments that require the implementation of various functions and classes in Python. Tasks include defining functions for prime numbers, matrix operations, and string manipulations, as well as creating classes for 2D and 3D points. Each assignment emphasizes the use of specific programming concepts such as lists, dictionaries, and exception handling.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

INDEX

SL. ASSIGNMENT STATEMENT TEACHER


NO SIGNATURE
Define a function prime(n) that returns True if n is prime and
0 otherwise. Use this function to do the following:
• Print the prime factors of a number.
• Print the first 10 terms of prime Fibonacci series.
• Test whether a number is a prime product or not.
1 (Note: A positive integer m is a prime product if it can be
written as p×q, where p and q are both primes.)
You may use separate functions for each of the above three
problems
Write a function contracting(l) that takes as input a list of
2 integersl and returns True if the absolute difference between
each adjacent pair of elements strictly decreases; and False
otherwise
Write a program that shuffles two lists l1 and l2 in a third list
sl in the following manner: sl should consist of the first
element in l1, then the first element in l2, then the second
element inl1, then the second element in l2, and so on. If
3 the two lists are not of equal length, the remaining
elements of the longer list are appended at the end ofsl.
In a list of integers l, the neighbours of l[i] are l[i-1] and
l[i+1]. l[i] is a hill if it is strictly greater than its neighbours
and a valley if it is strictly less than its neighbours.
4 Define a function counthv(l) that takes as input a list of
integers las argument and returns a list [hc,vc] where hc is
the number of hills in l and vc is the number of valleys in l
Write a program to perform matrix addition, matrix
subtraction and matrix multiplication by simulating matrix
using list of lists. You may use separate functions for each
5
operation
Write a program to do Gaussian addition on a list of
numbers. Print each partial sum and also the final sum. The
program should be able to handle lists having both odd
lengths and even lengths.
6 (Eg: If the list is [11, 2, 30, 40, 5, 6], the program should
output “11 + 6 =17”, “2 + 5=7”, and “30 + 40 = 70” in
separate lines, and the result of the addition “94”.)
Write a program that finds the Jaccard similarities between

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.

You might also like