You are on page 1of 2

Bangalore Institute of Technology

Department of Computer Science and Engineering


II Internals
SUB (CODE): Application Development Using Python (18CS55) SEM: 5 BATCH: 2018
DATE & TIME: 13-11-2020, 09.30AM – 11.30AM MAX MARKS: 30+10
USN:

Note: Answer any one full question from each part.


Part A Marks COs POs
1. a) List and explain the methods (at least 6) that operate on lists, with appropriate examples. 6

b) Write a program which repeatedly reads numbers, until the user enters “done”. Once
“done” is entered print out the total, count and average of numbers. (Use built-in functions and 5
methods of list). Use try and except to print an error message for a wrong input.

c) Write a program to print out the day of the week form those lines that start with “From”. 5
Sample input line: From stephen.marquard@uct.ac.zaSat Jan 5 09:14:16 2008)

d) Define dictionaries with an example. Write a program to check if a given key is already
exists in a dictionary. 2 1,2,3
4
OR
2. a) Create a dictionary to count the occurrence of letters in a given word.
(word = “openelective” ) 6
b) Illustrate the use of get method of dictionary using program.
c) Illustrate advanced text processing by creating a dictionary for the actual text shown 4
below:
10
But, soft! What? light through yonder window breaks?
It is the east, and Juliet is the sun

Part B
3. a) Write a program to sort the following dictionary, in ascending alphabetical order by the 5
key value.
d = {'b':10, 'c':1, 'a':22}
b) Describe Regular expression and list the meta characters. Write a program to search for 5
lines that have an @ sign between characters and the characters must begin and end with letter.
OR
4. a) Write a Python program to get a string made of the first 3 and the last 2 chars from a given 2 1,2,3
a string. If the string length is less than 4, return empty string. 4
b) Write a Python program to output a string from a given string where all occurrences of its 6
first char have been changed to '#', except the first char itself.

Sample String : 'restart'


Expected Result : 'resta#t'

1. CO2: Analyze the given problem statement to use the concepts like lists, dictionaries and regular
expressions in developing applications.
Python Application Programming --- Quiz
1. ______ is the output of the following statement?
[1, 2, 3] * 3
a) [3, 6, 9] b) [1, 2, 3, 3] c) Error d) [1, 2, 3, 1, 2, 3, 1, 2, 3]

2. List is mutable
a) True b) False

3. Which of the following statements create a dictionary?


a) d = {} b) d = {“john”:40, “peter”:45} c) d = {40:”john”, 45:”peter”} d) All of the
mentioned

4. What will be the output?


d = {"john":40, "peter":45}
"john" in d
a) True b) False c) None d) Error

5. Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary which command do
we use?
a) d.size() b) len(d) c) size(d) d) d.len()
6. Suppose d = {“john”:40, “peter”:45}, what happens when we try to retrieve a value using the expression
d[“susan”]?
a) Since “susan” is not a value in the set, Python raises a KeyError exception
b) It is executed fine and no exception is raised, and it returns None
c) Since “susan” is not a key in the set, Python raises a KeyError exception
d) Since “susan” is not a key in the set, Python raises a syntax error

7. The character Dot (that is, ‘.’) in the default mode, matches any character other than _____________
a) caret b) ampersand c) percentage symbol d) newline

8. ________ matches the start of the string and ________ matches the end of the string.
a) ‘^’, ‘$’ b) ‘$’, ‘^’ c) ‘$’, ‘?’ d) ‘?’, ‘^’

9. ______ is the character set used to skip something from pattern matching.
a) ( ) b) { } c) [ ] d) & &

10. String are mutable.


a) True b) False

Faculty Incharge

Course Co-ordinator Module Coordinator IQAC NBA Co-ordinator Programme Co-ordinator

You might also like