You are on page 1of 1

C Byregowda Institute of Technology

Feb - May 2019 | Python Application Programming (15CS664) | SEM VI


Mrs. Harshitha PR Ms. Suvika KV
Assignment # 02
Date of issue: 09/04/2019 | Submission Due: 16/04/2019

1. What are lists? Lists are mutable. Justify the statement with examples.
2. How tuples are created in Python? Explain different ways of accessing and creating them.
3. Explain join( ), split( ), pop(), del(), remove() and append( ) methods in a list with examples.
4. Define tuple. Explain DSU pattern with program.
5. How are dictionaries and tuples used together? Demonstrate the use of tuple assignment with
dictionaries to traverse the keys and values of dictionary.
6. Explain copying an object in python.

Programs

1. How class can be instantiated in python? Write a python program to express instances as return
values to define a class RECTANGLE with members width, height, corner_x, corner_y and member
function : to find center, area and perimeter of a rectangle.
2. Write a function called draw_circle that takes Turtle and Circle and draws a circle.
3. Write a Pytho program to accept a file name from the user:
i. Display the first N-lines of the file.
ii. Find the frequency of occurrence of the word accepted from the user in the file.
4. Write Pythonic code to multiply two matrices using nested loops and also perform transpose of the
resultant matrix.
5. Write a Python program to read all the lines in a file accepted from the user and print all email
addresses contained in it. Assume the email addresses contain only non-while space characters.
6. Write a Pytho program to search for lines that start with the word ‘FROM’ and a character followed
by a two digit number 00 and 99 followed by ‘:’ Print the number if it is greater than zero. Assume
any input file.
7. Describe any two list operations and list methods. Write a python program to accept ‘n’
numbers from user, find sum all even numbers and product of all odd numbers in entered list.
8. Write pythonic code that implements and returns the functionality of histogram using dictionaries.
Also, write the function print_hist to print the keys and their values in alphabetical order from the
values returned by the histogram function.
9. Consider a file “ait.txt”. Write a Python program to read the file and look for lines of the form

X-DSPAM-Confidence: 0.875
X-DSPAM-Probability: 0.458
Extract the number from each of the lines using a regular expression. Compute the average of the
numbers and print out the average.

You might also like