Python Application Programming Important Questions

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Python Application Programming Important Questions

1. What is a list? Briefly explain traversing a list, list operations and list slices with code
snippets
2. Explain the following methods of list with code snippets
a. append
b. extend
c. pop
d. remove
e. len, max, min
3. Explain the use of list, split and join methods in Lists with code examples.
4. Write a program to read a line from a text file, perform right strip on the line, split
the line and display the words in this line.
(line : Hello World, read this line and convert into list and read each and every word
and display the words in the list as index)

5. What is a dictionary? With code snippets explain how to create an empty dictionary,
add three items into this dictionary, and read the keys and values of this dictionary.
6. Write a program to read the word ‘brontosaurus’ and store each letter as key and
the total count of each letter in the word as the value in the dictionary and display it.
7. Here is the txt file ‘Junk.txt’ which has 4 lines (refer the file), write a program to read
this text file and read all the lines of this text file and split each word in the line and
store it as a key and the total count of the words as values in the dictionary and
display the dictionary.
8. Briefly explain the use of string.punctuation and translate() function with the help of
a program.
9. What are tuples? Justify that tuples are immutable with example
10. Write a program to store the dictionary items obtained in Question No.7 in
tuples/lists and perform sorting of these items based on value/count obtained.
11. What are regular expressions? Consider junk.txt file, write a program to search for
lines that contains ‘From’.
12. Write a program to search for lines that have an @ sign between characters (must
be a letter or number) in junk.txt
13. Write a program to search for lines that start with ‘Details: rev=’ followed by
numbers and ‘.’, then print the number if it is greater than zero in junk.txt using
regular expression methods.
14. Briefly explain what are classes and objects. Create Point Class and Rectangle class,
add the attributes x, y for Point and width, height, corner for Rectangle class. Create
an object of point class and assign to corner attribute and explain this with code
snippets
15. With code snippets explain how to copy the objects and explain what happens in
shallow copy and deep copy.
16. Explain pure functions and modifiers in a class.
17. Explain the following
a. __init__ method
b. __str__ method
c. Operator Overloading
d. Type based dispatch
e. Polymorphism

--------------------------------------------------------------------------------------------------------------------------
Junk.txt

1. But, soft! what light through yonder window breaks?


2. It Is the east, From: [email protected] and From: [email protected](( is
the sun.
3. Romeo and Juliet is the sun.
4. From: [email protected]$
5. Arise, fair sun, and kill the envious moon, Fram:
[email protected]#
6. Who is already sick and pale with grief,
7. But, soft! what light through yonder window breaks?
8. From: stupid gmail.com&
9. From [email protected] Sat Jan 5 09:14:16 2008
10. Return-Path: <[email protected]>
11. for <[email protected]>;
12. Received: (from apache@localhost)
13. Author: [email protected]
14. X-DSPAM-Confidence: 0.8475
15. X DSPAMProbability: 0.0000
16. Details: http://source.sakaiproject.org/viewsvn/?view=rev&rev=39772
17. From [email protected] Sat Jan 5 23:14:16 2008
18. 'We just received $10.00 for cookies.'
19. Details: http://source.sakaiproject.org/viewsvn/?view=rev&rev=abde

You might also like