Francis Xavier Engineering College: (Autonomous)
Francis Xavier Engineering College: (Autonomous)
Francis Xavier Engineering College: (Autonomous)
4. When does the else statement written after loop a) List b) Array
executes?
c) Tuple d) None of these
a) When break b) When loop condition
statement is becomes false 12. Identify the operations in List
executed in the loop
a) Indexing b) Slicing
c) Else statement is d) None of the above
always executed c) Concatenation d) All of these
5. Identify the keyword for pass statement 13. What is the purpose of slicing?
18. Identify the method that Reverses the order of c) Key:reference pair d) None of these
items in the list
27. All elements in the dictionary are placed inside the
a) a.reverse() b) Change() ___
20. Creating a copy of a list is called ____ c) Both a and b d) None of these
a) aliasing b) copying 29. The method used to add the dictionary with the
existing dictionary
c) listing d) None of these
a) a.update(dictionar b) edit(Dictionary)
21. _____is a process of making a copy of the list y)
without modifying the original list.
c) Change(dictionary) d) None of these
a) Aliasing b) copying
30. _______provide a concise way to apply operations
c) Cloning d) All of these on a list.
24. ______can be used as keys in dictionaries 32. Identify the features of Text files
a) textfile b) Binary file 41. Errors can also occur at runtime and these are
called ____
c) Readable file d) All of these
a) exceptions b) Syntax error
34. Overwrite the contents of file with new contents by
opening a file using ____ c) semantic error d) None of these
a) Read mode b) Append mode 42. Identify the possible exceptions at runtime
a) When you open a file b) When you open a file c) module we try to d) All of these
for reading, if the for writing, if the file import is not found
file does not exist, does not exist, a new (ImportError)
an error occurs file is created
43. Python exception that Raised when attribute
c) When you open a file d) All of these assignment or reference fails
for writing, if the file
exists, the existing a) AttributeError b) FloatingPointError
file is overwritten
with the new file c) ImportError d) IndexError
36. Identify to function to determine whether a file 44. ____is a file containing Python definitions and
exists. statements
37. Identify the module used for command line 45. Identify the python modules
arguments
a) random b) Decimal
a) system b) cons
c) Htmal.parser d) All of these
c) sys d) All of these
46. _____is a collection of modules
38. ____is any issue that arises unexpectedly that
causes a computer to not function properly. a) A package b) Nested module
a) A mistake b) A fault
c) files d) All of these
c) An error d) All of these 47. The main difference between a module and a
package is that a package is
39. Identify the basic errors
a) A collection of files b) Collection of modules
a) Syntax error(parsing b) Exception(Runtime
errors) errors)
c) A collection of d) All of these
modules AND it has
c) Both a and b d) None of these an __init__.py file.
40. Error caused by not following the proper structure 48. Identify the format operstor
FRANCIS XAVIER ENGINEERING COLLEGE (AUTONOMOUS)
COMMON ASSESSMENT TEST -2
ODD SEMESTER 20-21
COURSE: 19CS1501 PYTHON PROGRAMMING
a) % b) = a) a result tuple b) a result dictionary
49 It is a process that enables a program to deal with 56. Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is
the exceptions and continue its normal execution. len(listExample)?
50. Python Exception that Raised when the imported 57. Suppose list1 is [1, 5, 9], what is sum(list1)?
module is not found
a) 1 b) 9
a) FloatingPointError b) EOFError
c) 15 d) None of these
c) ImportError d) All the these
58. Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the
51. What will be the output of the following Python following is correct syntax for slicing operation?
code?
for i in range(0,2,-1): a) print(list1[0]) b) print(list1[:2])
print("Hello")
Note: Q.No 51 to 75 Carries 2 Marks c) print(list1[:-2]) d) All the mentioned
a) Hello b) Hello Hello 59. What will be the output of the following
c) No Output d) Error Python code
54. What will be the output of the following code? 61. What will be the output of the following Python
x=5 code?
for i in x: >>>t = (1, 2)
print(i) >>>2 * t
a) 12 b) 12 a) (1, 2, 1, 2) b) [1, 2, 1, 2]
55. The list comprehension always returns _____ 62. What will be the output of the following Python
code snippet?
FRANCIS XAVIER ENGINEERING COLLEGE (AUTONOMOUS)
COMMON ASSESSMENT TEST -2
ODD SEMESTER 20-21
COURSE: 19CS1501 PYTHON PROGRAMMING
d1 = {"john":40, "peter":45} a) Bracket is missing b) No error
d2 = {"john":466, "peter":45}
d1 > d2 c) a colon is missing d) None of these
in the if statement
a) True b) False
68. What will be the output of the following Python
c) Error d) None code?
d = {"john":40, "peter":45} 69. To read the next line of the file from a file object
print(list(d.keys())) infile, we use ____________
c) infile.readline() d) infile.readlines()
c) (“john”, “peter”) d) (“john”:40, “peter”:45)
70. Find the output of this code
65. Suppose d = {“john”:40, “peter”:45}, what print(“We are using python %d version”%(3))
happens when we try to retrieve a value using the
expression d[“susan”]? a) We are using b) We are using python
python 3 version %d version
a) Since “susan” is not b) It is executed fine and
a value in the set, no exception is raised, c) We are using d) None of these
Python raises a and it returns None python3version3
KeyError exception
71. Find the output of the following program
c) Since “susan” is d) Since “susan” is not a import sys
not a key in the key in the set, Python m1=int(sys.argv[1])
set, Python raises raises a syntax error m2=int(sys.argv[2])
a KeyError m3=m1*m2
exception print('The multiplied value is: %d' %(m3))
def foo():
try:
print(1)
finally:
print(2)
foo()
a) 12 b) 2
c) 3 d) None of these
a) 20 b) Nothing is printed
#mod1
def change(a):
b=[x*2 for x in a]
print(b)
#mod2
def change(a):
b=[x*x for x in a]
print(b)
from mod1 import change
from mod2 import change
#main
s=[1,2,3]
change(s)
a) [2,4,6] b) [1,4,9]