Get Latest Exam Updates, Free Study materials and Tips

Q.1:

Is Python case sensitive when dealing with identifiers?

A) Yes B) No
C) Machine dependent D) None of the mentioned
Q.2:

What is the maximum possible length of an identifier?

A) 31 characters B) 63 characters
C) 79 characters D) None of the mentioned
Q.3:

Which of the following is invalid?

A) _a = 1 B) __a = 1
C) __str__ = 1 D) None of the mentioned
Q.4:

Which of the following is an invalid variable?

A) my_string_1 B) 1st_string
C) foo D) _
Q.5:

Why are local variable names beginning with an underscore discouraged?

A) they are used to indicate a private variables of a class B) they confuse the interpreter
C) they are used to indicate global variables D) they slow down execution
Q.6:

Which of the following is not a keyword?

A) eval B) assert
C) nonlocal D) pass
Q.7:

All keywords in Python are in _________

A) lower case B) UPPER CASE
C) Capitalized D) None of the mentioned
Q.8:

Which of the following is true for variable names in Python?

A) unlimited length B) all private members must have leading and trailing underscores
C) underscore and ampersand are the only two special characters allowed D) none of the mentioned
Q.9:

Which of the following is an invalid statement?

A) abc = 1,000,000 B) a b c = 1000 2000 3000
C) a,b,c = 1000, 2000, 3000 D) a_b_c = 1,000,000
Q.10:

Which of the following cannot be a variable?

A) __init__ B) in
C) it D) on
Q.11:

Which is the correct operator for power(xy)?

A) X^y B) X**y
C) X^^y D) None of the mentioned
Q.12:

Which one of these is floor division?

A) / B) //
C) % D) None of the mentioned
Q.13:

What is the order of precedence in python?

i) Parentheses

ii) Exponential

iii) Multiplication

iv) Division

v) Addition

vi) Subtraction

A) i,ii,iii,iv,v,vi B) ii,i,iii,iv,v,vi
C) ii,i,iv,iii,v,vi D) i,ii,iii,iv,vi,v
Q.14:

What is the answer to this expression, 22 % 3 is?

A) 7 B) 1
C) 0 D) 5
Q.15:

Mathematical operations can be performed on a string.

A) True B) False
Q.16:

Operators with the same precedence are evaluated in which manner ?

A) Left to Right B) Right to Left
C) Can’t say D) None of the mentioned
Q.17:

What is the output of this expression, 3*1**3 ?

A) 27 B) 9
C) 3 D) 1
Q.18:

Which one of the following has the same precedence level?

A) Addition and Subtraction B) Multiplication, Division and Addition
C) Multiplication, Division, Addition and Subtraction D) Addition and Multiplication
Q.19:

The expression Int(x) implies that the variable x is converted to integer.

A) True B) False
Q.20:

Which one of the following has the highest precedence in the expression?

A) Exponential B) Addition
C) Multiplication D) Parentheses
Q.21:

What is the output of print 0.1 + 0.2 == 0.3?

A) True B) False
C) Machine dependent D) Error
Q.22:

Which of the following is not a complex number?

A) k = 2 + 3j B) k = complex(2, 3)
C) k = 2 + 3l D) k = 2 + 3J
Q.23:

What is the type of inf ?

A) Boolean B) Integer
C) Float D) Complex
Q.24:

What does ~4 evaluate to ?

A) -5 B) -4
C) -3 D) +3
Q.25:

What does ~~~~~~5 evaluate to?

A) +5 B) -11
C) +11 D) -5
Q.26:

Which of the following is incorrect?

A) x = 0b101 B) x = 0x4f5
C) x = 19023 D) x = 03964
Q.27:

What is the result of cmp(3, 1)?

A) 1 B) 0
C) True D) False
Q.28:

Which of the following is incorrect?

A) float(‘inf’) B) float(‘nan’)
C) float(’56’+’78’) D) float(’12+34′)
Q.29:

What is the result of round(0.5) – round(-0.5) ?

A) 1.0 B) 2.0
C) 0.0 D) Value depends on Python version
Q.30:

What does 3 ^ 4 evaluate to ?

A) 81 B) 12
C) 0.75 D) 7
Q.31:

Which of the following statements assigns the value 25 to the variable x in Python:

A) x ← 25 B) x = 25
C) int x = 25 D) x << 25
Q.32:

In Python, a variable may be assigned a value of one type, and then later assigned a value of a different type:

A) False B) True
Q.33:

Which one of the following is the correct way of declaring and initializing a variable, x with the value 7 ?

A) x=7 B) int x
C) int x=7 D) declare x=7
Q.34:

What will be the output of statement 2**2**2**2

A) 16 B) 256
C) 32768 D) 65536
Q.35:

Which of the following statement is False ?

A) Variable names can be arbitrarily long. B) They can contain both letters and numbers.
C) Variable name can begin with underscore. D) Variable name can begin with number.
Q.36:

What is the output of the following code: print 9//2

A) 4 B) 4.5
C) 4.0 D) Error
Q.37:

Which of the following is not a valid variable name in Python?

A) _var B) var_name
C) var11 D) 5var
Q.38:

What is the maximum length of an identifier in python?

A) 32 B) 31
C) 63 D) None of the above
Q.39:

Which of the following declarations is incorrect?

A) None Of the below B) _x = 2
C) __x = 3 D) __xyz__ = 5
Q.40:

What is the result of round(0.5) – round(-0.5)?

A) 1.0 B) 2.0
C) 0 D) None Of the above
Q.41:

What is the result of executing the following code?

number = 5

while number <= 5:

if number < 5:

number = number + 1

print(number)

A) The program will loop indefinitely B) The value of number will be printed exactly 1 time
C) The while loop will never get executed D) The value of number will be printed exactly 5 times
Q.42:

What will the following code print ?

counter = 1

sum = 0

while counter <= 6:

sum = sum + counter

counter = counter + 2

print(sum)

A) 12 B) 9
C) 7 D) 8
Q.43:

What will be printed by the following code when it executes?

sum = 0

values = [1,3,5,7]

for number in values:

sum = sum + number

print(sum)

A) 4 B) 0
C) 7 D) 16
Q.44:

What is the last thing printed when the following code is run ?

number = 0

while number <= 10:

print("Number: ", number)

number = number + 1

A) Number: 10 B) Number: number
C Number: 0 D) Number: 11
Q.45:

What does the following code print ?

output = ""

x = -5

while x < 0:

x = x + 1

output = output + str(x) + " "

print(output)

A) 5 4 3 2 1 B) -4 -3 -2 -1 0
C) -5 -4 -3 -2 -1 D) This is an infinite loop, so nothing will be printed
Q.46:

What are the values of var1 and var2 that are printed when the following code executes ?

output = ""

var1 = -2

var2 = 0

while var1 != 0:

var1 = var1 + 1

var2 = var2 - 1

print("var1: " + str(var1) + " var2 " + str(var2))

A) var1 = -2, var2 = 0 B) var1 = 0, var2 = -2
C) var1 = 0, var2 = -1 D) This is an infinite loop, so nothing will be printed
Q.47:

How many asterisks will be printed when the following code executes? for x in [0, 1, 2, 3]: for y in [0, 1, 2, 3, 4]: print('*')

A) 0 B) 4
C) 5 D) 20
Q.48:

The following code contains an infinite loop. Which is the best explanation for why the loop does not terminate ?

n = 10 answer = 1 while n > 0: answer = answer + n n = n + 1 print(answer)

A) n starts at 10 and is incremented by 1 each time through the loop, so it will always be positive. B) answer starts at 1 and is incremented by n each time, so it will always be positive.
C) You cannot compare n to 0 in the while loop. You must compare it to another variable. D) In the while loop body, we must set n to False, and this code does not do that.
Q.49:

Which type of loop can be used to perform the following iteration: You choose a positive integer at random and then print the numbers from 1 up to and including the selected integer.

A) a for-loop or a while-loop B) only a for-loop
C) only a while-loop D) a for-loop And a while-loop
Q.50:

Which of the following statements won’t be printed when this Python code is run?

for letter in 'Python': if letter == 'h': continue print('Current Letter : ' + letter)

A) Current Letter : P B) Current Letter : t
C) Current Letter : h D) Current Letter : o
Q.51:

for i in range(-3), how many times this loop will run ?

A) 0 B) 1
C) Infinite D) Error
Q.52:

for i in [1,2,3]:, how many times a loop run ?

A) 0 B) 1
C) 2 D) 3
Q.53:

for loop in python are work on

A) range B) iteration
C) Both of the above D) None of the above
Q.54:

How many times it will print the statement ?, for i in range(100): print(i)

A) 101 B) 99
C) 100 D) 0
Q.55:

For loop in python is

A) Entry control loop B) Exit control loop
C) Simple loop D) None of the above
Q.56:

In which of the following loop in python, we can check the condition ?

A) for loop B) while loop
C) do while loop D) None of the above
Q.57:

It is possible to create a loop using goto statement in python ?

A) Yes B) No
C) Sometimes D) None of the above
Q.58:

To break the infinite loop , which keyword we use ?

A) continue B) break
C) exit D) None of the above
Q.59:

l=[],for i in l: print(l), what is the output ?

A) [] B) list
C) print() D) None of the above
Q.60:

What is the final value of the i after this, for i in range(3): pass

A) 1 B) 2
C) 3 D) 0
Q.61:

What is the value of i after the for loop ?, for i in range(4):break

A) 0 B) 1
C) 3 D) 2
Q.62:

What we put at the last of the loop ?

A) semicolon B) colon
C) comma D) None of the above
Q.63:

which of the following is consider as a infinite loop

A) while(infinte): B) while(1):
C) for(1): D) None of the above
Q.64:

Which of the following is Exit control loop in python ?

A) for loop B) while loop
C) do while loop D) None of the above
Q.65:

Which of the following is the loop in python ?

A)for B) while
C) do while D) 1 and 2
Q.66:

Which of the following loop is not supported by the python programming language ?

A) for loop B) while loop
C) do while loop D) None of the above
Q.67:

Which of the following loop is work on the particular range in python ?

A) for loop B) while loop
C) do while loop D) recursion
Q.68:

While(0), how many times a loop run ?

A) 0 B) 1
C) 3 D) infinite
Q.69:

while(1): print(2), How many times a loops run ?

A) 1 B) 2
C) 3 D) None of the above
Q.70:

while(1==3):, how many times a loop run ?

A) 1 B) infinite
C) 3 D) 0
Q.1:

Which of the following would give an error?

A) list1=[] B) list1=[]*3
C) list1=[2,8,7] D) None of the above
Q.2:

Which of the following is True regarding lists in Python?

A) Lists are immutable. B) Size of the lists must be specified before its initialization
C) Elements of lists are stored in contagious memory location. D) size(list1) command is used to find the size of lists.
Q.3:

What will be the output of below Python code?

list1=[8,0,9,5]

print(list1[::-1])

A) [5,9,0,8] B) [8,0,9]
C) [8,0,9,5] D) [0,9,5]
Q.4:

Which of the following will give output as [23,2,9,75] ?

If list1=[6,23,3,2,0,9,8,75]

A) print(list1[1:7:2]) B) print(list1[0:7:2])
C) print(list1[1:8:2]) D) print(list1[0:8:2])
Q.5:

The marks of a student on 6 subjects are stored in a list, list1=[80,66,94,87,99,95]. How can the student’s average mark be calculated?

A) print(avg(list1)) B) print(sum(list1)/len(list1))
C) print(sum(list1)/sizeof(list1)) D) print(total(list1)/len(list1))
Q.6:

What will be the output of following Python code?

list1=["Python","Java","c","C","C++"]

print(min(list1))

A) c B) C++
C) C D) min function cannot be used on string elements
Q.7:

The elements of a list are arranged in descending order. Which of the following two will give same outputs?

i. print(list_name.sort())

ii. print(max(list_name))

iii. print(list_name.reverse())

iv. print(list_name[-1])

A) i, ii B) i, iii
C) ii, iii D) iii, iv
Q.8:

What will be the result after the execution of above Python code ?

list1=[3,2,5,7,3,6]

list1.pop(3)

print(list1)

A) [3,2,5,3,6] B) [2,5,7,3,6]
C) [2,5,7,6] D) [3,2,5,7,3,6]
Q.9:

What will be the output of below Python code?

list1=[1,3,5,2,4,6,2]

list1.remove(2)

print(sum(list1))

A) 18 B) 19
C) 21 D) 22
Q.10:

What will be the output of below Python code ?

list1=["tom","mary","simon"]

list1.insert(5,8)

print(list1)

A) ["tom", "mary", "simon", 5] B) ["tom", "mary", "simon", 8]
C) [8, "tom", "mary", "simon"] D) Error
Q.11:

Which of the following is a Python tuple ?

A) [1, 2, 3] B) (1, 2, 3)
C) {1, 2, 3} D) {}
Q.12:

Suppose t = (1, 2, 4, 3), which of the following is incorrect?

A) print(t[3]) B) t[3] = 45
C) print(max(t)) D) print(len(t))
Q.13:

What will be the output of the following Python code?

>>>t=(1,2,4,3)

>>>t[1:3]

A) (1, 2) B) (1, 2, 4)
C) (2, 4) D) (2, 4, 3)
Q.14:

What will be the output of the following Python code?

>>>t = (1, 2, 4, 3, 8, 9)

>>>[t[i] for i in range(0, len(t), 2)]

A) [2, 3, 9] B) [1, 2, 4, 3, 8, 9]
C) [1, 4, 8] D) (1, 4, 8)
Q.15:

What will be the output of the following Python code?

>>>t=(1,2,4,3)

>>>t[1:-1]

A) (1, 2) B) (1, 2, 4)
C) (2, 4) D) (2, 4, 3)
Q.16:

What will be the output of the following Python code ?

d = {"john":40, "peter":45}

d["john"]

A) 40 B) 45
C) “john” D) “peter”
Q.17:

What will be the output of the following Python code?

>>>t = (1, 2)

>>>2 * t

A) (1, 2, 1, 2) B) [1, 2, 1, 2]
C) (1, 1, 2, 2) D) [1, 1, 2, 2]
Q.18:

What will be the output of the following Python code?

>>>t1 = (1, 2, 4, 3)

>>>t2 = (1, 2, 3, 4)

>>>t1 < t2

A) True B) False
C) Error D) None
Q.19:

What will be the output of the following Python code?

>>>my_tuple = (1, 2, 3, 4)

>>>my_tuple.append( (5, 6, 7) )

>>>print len(my_tuple)

A) 1 B) 2
C) 5 D) Error
Q.20:

What will be the output of the following Python code ?

numberGames = {}

numberGames[(1,2,4)] = 8

numberGames[(4,2,1)] = 10

numberGames[(1,2)] = 12

sum = 0

for k in numberGames:

sum += numberGames[k]

print len(numberGames) + sum

A) 30 B) 24
C) 33 D) 12
Q.21:

Which of the following statements is used to create an empty set?

A) { } B) set()
C) [ ]. D) ( )
Q.22:

What is the output of the following piece of code when executed in the python shell?

a={1,2,3} 

a.intersection_update({2,3,4,5}) 

a

A) {2,3} B) Error, duplicate item present in list
C) Error, no method called intersection_update for set data type D) {1,4,5}
Q.23:

Which of the following lines of code will result in an error ?

A) s={abs} B) s={4, ‘abc’, (1,2)}
C) s={2, 2.2, 3, ‘xyz’} D) s={san}
Q.24:

What is the output of the code shown below ?

s=set([1, 2, 3])

s.union([4, 5])

s|([4, 5])

A) {1, 2, 3, 4, 5}{1, 2, 3, 4, 5} B) Error{1, 2, 3, 4, 5}
C) {1, 2, 3, 4, 5}Error D) ErrorError
Q.25:

What is the output of the line of code shown below,

if s1= {1, 2, 3}?

s1.issubset(s1)

A) True B) Error
C) No output D) False
Q.26:

Which of these about a frozenset is not true?

A) Mutable data type B) Allows duplicate values
C) Data type with unordered values D) Immutable data type
Q.27:

Is the following Python code valid?

>>> a=frozenset([5,6,7])

>>> a

>>> a.add(5)

A) Yes, now a is {5,5,6,7} B) No, frozen set is immutable
C) No, invalid syntax for add method D) Yes, now a is {5,6,7}
Q.28:

What is the syntax of the following Python code ?

>>> a=frozenset(set([5,6,7]))

>>> a

A) {5,6,7} B) frozenset({5,6,7})
C) Error, not possible to convert set into frozenset D) Syntax error
Q.29:

Set members must not be hashable.

A) True B) False
Q.30:

What will be the output of the following Python code?

>>> a={3,4,5}

>>> a.update([1,2,3])

>>> a

A) Error, no method called update for set data type B) {1, 2, 3, 4, 5}
C) Error, list can’t be added to set D) Error, duplicate item present in list
Q.31:

What will be the output of the following Python code?

>>> a={1,2,3}

>>> b=a

>>> b.remove(3)

>>> a

A) {1,2,3} B) Error, copying of sets isn’t allowed
C) {1,2} D) Error, invalid syntax for remove
Q.32:

What will be the output of the following Python code?

>>> a={1,2,3}

>>> a.intersection_update({2,3,4,5})

>>> a

A) {2,3} B) Error, duplicate item present in list
C) Error, no method called intersection_update for set data type D) {1,4,5}
Q.33:

What will be the output of the following Python code?

>>> a={1,2,3}

>>> b=a.copy()

>>> b.add(4)

>>> a

A) {1,2,3} B) Error, invalid syntax for add
C) {1,2,3,4} D) Error, copying of sets isn’t allowed
Q.34:

What will be the output of the following Python code?

>>> a={1,2,3}

>>> b=a.add(4)

>>> b

A) 0 B) {1,2,3,4}
C) {1,2,3} D) Nothing is printed
Q.35:

What will be the output of the following Python code?

>>> a={1,2,3}

>>> b=frozenset([3,4,5])

>>> a-b

A) {1,2} B) Error as difference between a set and frozenset can’t be found out
C) Error as unsupported operand type for set data type D) frozenset({1,2})
Q.36:

What will be the output of the following Python code?

>>> a={1,2,3}

>>> {x*2 for x in a|{4,5}}

A) {2,4,6} B) Error, set comprehensions aren’t allowed
C) {8, 2, 10, 4, 6} D) {8,10}
Q.37:

What will be the output of the following Python code?

>>> a={5,6,7}

>>> sum(a,5)

A) 5 B) 23
C) 18 D) Invalid syntax for sum method, too many arguments
Q.38:

What will be the output of the following Python code?

>>> a={5,6,7,8}

>>> b={7,8,9,10}

>>> len(a+b)

A) 8 B) Error, unsupported operand ‘+’ for sets
C) 6 D) Nothing is displayed
Q.39:

What will be the output of the following Python code?

a={1,2,3}

b={1,2,3}

c=a.issubset(b)

print(c)

A) True B) Error, no method called issubset() exists
C) Syntax error for issubset() method D) False
Q.40:

Is the following Python code valid ?

a={1,2,3}

b={1,2,3,4}

c=a.issuperset(b)

print(c)

A) False B) True
C) Syntax error for issuperset() method D) Error, no method called issuperset() exists
Q.41:

Which line of code correctly initializes ‘grapes’ into the fruits dictionary?
fruits = {'apples': 1, 'bananas': 4, 'pears': 17, 'oranges': 14}

A) fruit['grapes'] B) fruit['grapes'] = 15
C) none D) insert 'grapes' in fruit
Answer & Explanation
Q.42:

What prints when the following code is run?
names = {'Janice': 5, 'Emily': 3, 'John': 7, 'Eleanor': 2}
list_o_names = []
for name in names:
if names[name] > 5:
list_o_names.append(name)
print(list_o_names

A) ['Janice', 'John'] B) ['Janice', 'Emily', 'Eleanor']
C) ['John'] D) none
Answer & Explanation
Q.43:

What does the following code print now that it has been updated?
names = {'Janice': 5, 'Emily': 3, 'John': 7, 'Eleanor': 2}
list_o_names = []
names['Emily'] += 10
names['Erik'] = 22
for name in names:
if names[name] > 5:
list_o_names.append(name)
print(list_o_names)

A) ['Emily', 'John', 'Erik'] B) ['Janice', 'Emily', 'John']
C) ['Janice', 'John', 'Erik'] D) cannot be determined
Answer & Explanation
Q.44:

What is the value of counter after the code is run to completion?
phrase = "Cheese in Philadelphia is extraordinary according to Erik"
counter = 0 letters = {} for word in phrase.split(): for letter in word: letter = letter.lower() if letter not in letters.keys(): letters[letter] = 0 letters[letter] += 1 for key in letters.keys(): if letters[key] > 2: counter += 1

A) 5 B) 10
C) 9 D) 8
Answer & Explanation
Q.45:

Which line of code correctly grabs the value of the key ‘apples’?
fruits = {'bananas': 7, 'apples': 4, 'grapes': 19, 'pears': 4}

A) fruits.get(apples) B) fruits.get('apples', 0)
C) fruits.get('apple') D) fruits.get(apples, 0)
Answer & Explanation
Q.46:

What value is printed once the code is run?

word = 'brontosaurus'
diction = {}
for letter in word:
if letter not in diction.keys():
diction[letter] = 0
diction[letter] += 1
print(diction.get('o', 0) + 4)

A) 10 B) 4
C) 8 D) 6
Answer & Explanation
Q.47:

What order do the keys print in after the following code is run? (Select all that apply)
counts = {'chuck' : 1, 'annie' : 42, 'jan' : 100}/
for key in counts:
print(key, counts[key])

A) jan, chuck, annie B) chuck, annie, jan
C) annie, chuck, jan D) All of these
Answer & Explanation
Q.48:

Which of the following is the correct way to initialize the string module?

A) import String B) import string
C) import string module D) none
Answer & Explanation
Q.49:

True or false? Python treats the words “Exciting” and “exciting” as the same word.

A)True B) False
Answer & Explanation
Q.50:

Which line of code correctly uses the .translate() method?

A) line.translate(str.maketrans(fromstr, tostr, deletestr)) B) line.translate(fromstr, tostr, deletestr)
C) line.translate(str.translate(fromstr, tostr, deletestr)) D) none
Answer & Explanation
Q.51:

NumPY stands for?

A) Numbering Python B) Number In Python
C) Numerical Python D) None Of the above
Answer & Explanation
Q.52:

NumPy is often used along with packages like?

A) Node.js B) Matplotlib
C) SciPy D) Both B and C
Answer & Explanation
Q.53:

The most important object defined in NumPy is an N-dimensional array type called?

A) ndarray B) narray
C) nd_array D) darray
Answer & Explanation
Q.54:

What will be output for the following code?
import numpy as np
a = np.array([1,2,3])
print a

A) [[1, 2, 3]] B) [1]
C) [1, 2, 3] D) Error
Answer & Explanation
Q.55:

What will be output for the following code?
import numpy as np
a = np.array([1, 2, 3], dtype = complex) print a

A) [[ 1.+0.j, 2.+0.j, 3.+0.j]] B) [ 1.+0.j]
C) Error D) [ 1.+0.j, 2.+0.j, 3.+0.j]
Answer & Explanation
Q.56:

Which of the following statement is false?

A) ndarray is also known as the axis array. B) ndarray.dataitemSize is the buffer containing the actual elements of the array.
C) NumPy main object is the homogeneous multidimensional array D) In Numpy, dimensions are called axes
Answer & Explanation
Q.57:

If a dimension is given as ____ in a reshaping operation, the other dimensions are automatically calculated.

A) Zero B) One
C) Negative one D) Infinite
Answer & Explanation
Q.58:

Which of the following sets the size of the buffer used in ufuncs?

A) bufsize(size) B) setsize(size)
C) setbufsize(size) D) size(size)
Answer & Explanation
Q.59:

What will be output for the following code?

import numpy as np
dt = dt = np.dtype('i4')
print dt

A) int32 B) int64
C) int128 D) int16
Answer & Explanation
Q.60:

Each built-in data type has a character code that uniquely identifies it.What is meaning of code "M"? r

A) timedelta B) datetime
C) objects D) Unicode
Answer & Explanation
Q.61:

The output of the code shown below is:

odd=lambda x: bool(x%2)
numbers=[n for n in range(10)]
print(numbers)
n=list()
for i in numbers:
  if odd(i):
  continue
else:
  break

A) [0, 2, 4, 6, 8, 10] B) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
C) [1, 3, 5, 7, 9] D) Error
Answer & Explanation
Q.62:

What is the output of the code shown below?

f=lambda x:bool(x%2)
print(f(20), f(21))

A) False True B) False False
C) True True D) True False
Answer & Explanation
Q.63:

What is the output of the code shown below?

import functools
l=[1,2,3,4]
print(functools.reduce(lambda x,y:x*y,l))

A) Error B) 10
C) 24 D) No output
Answer & Explanation
Q.64:

What is the output of the code shown?

l=[1, -2, -3, 4, 5]
def f1(x):
  return x<2
m1=filter(f1, l)
print(list(m1))

A) [1, 4, 5 ] B) Error
C) [-2, -3] D) [1, -2, -3]
Answer & Explanation
Q.65:

What is the output of the code shown below?

l=[-2, 4]
m=map(lambda x:x*2, l)
print(m)

A) [-4, 16] B) Address of m
C) Error D) -4
16
Answer & Explanation
Q.66:

What is the output of the following code?

l=[1, -2, -3, 4, 5]
def f1(x):
return x<-1 m1=map(f1, l)
print(list(m1))

A)[False, False, False, False, False] B) [False, True, True, False, False]
C) [True, False, False, True, True] D) [True, False, False, True, True]
Answer & Explanation
Q.67:

What is the output of the code shown?

l=[1, 2, 3, 4, 5]
m=map(lambda x:2**x, l)
print(list(m))

A) [1, 4, 9, 16, 25 ] B) [2, 4, 8, 16, 32 ]
C) [1, 0, 1, 0, 1] D) Error
Answer & Explanation
Q.68:

What is the output of the code shown?

import functools
l=[1, 2, 3, 4, 5]
m=functools.reduce(lambda x, y:x if x>y else y, l)
print(m)

A) Error B) Address of m
C) 1 D) 5
Answer & Explanation
Q.69:

What is the output of the code shown below?

l=[n for n in range(5)]
f=lambda x:bool(x%2)
print(f(3), f(1))
for i in range(len(l)):
  if f(l[i]):
  del l[i]
  print(i)

A) True True
1
2
Error
B) False False
1
2
C) True False
1
2
Error
D) False True
1
2
Answer & Explanation
Q.70:

What is the output of the code shown?

m=reduce(lambda x: x-3 in range(4, 10))
print(list(m))

A) [1, 2, 3, 4, 5, 6, 7] B) No output
C) [1, 2, 3, 4, 5, 6] D) Error
Answer & Explanation
Q.1:

To open a file c:\scores.txt for reading, we use _____________

A) infile = open(“c:\scores.txt”, “r”) B) infile = open(“c:\\scores.txt”, “r”)
C) infile = open(file = “c:\scores.txt”, “r”) D) infile = open(file = “c:\\scores.txt”, “r”)
Q.2:

To open a file c:\scores.txt for writing, we use ____________

A) outfile = open(“c:\scores.txt”, “w”) B) outfile = open(“c:\\scores.txt”, “w”)
C) outfile = open(file = “c:\scores.txt”, “w”) D) outfile = open(file = “c:\\scores.txt”, “w”)
Q.3:

To open a file c:\scores.txt for appending data, we use ____________

A) outfile = open(“c:\\scores.txt”, “a”) B) outfile = open(“c:\\scores.txt”, “rw”)
C) outfile = open(file = “c:\scores.txt”, “w”) D) outfile = open(file = “c:\\scores.txt”, “w”)
Q.4:

Which of the following statements are true ?

A) When you open a file for reading, if the file does not exist, an error occurs B) When you open a file for writing, if the file does not exist, a new file is created
C) When you open a file for writing, if the file exists, the existing file is overwritten with the new file D) All of the mentioned
Q.5:

To read two characters from a file object infile, we use ____________

A) infile.read(2) B) infile.read()
C) infile.readline() D) infile.readlines()
Q.6:

To read the entire remaining contents of the file as a string from a file object infile, we use ____________

A) infile.read(2) B) infile.read()
C) infile.readline() D) infile.readlines()
Q.7:

What will be the output of the following Python code?

f = None
for i in range (5):
with open("data.txt", "w") as f:
if i > 2:
break
print(f.closed)

A) True B) False
C) None D) Error
Q.8:

To read the next line of the file from a file object infile, we use ____________

A) infile.read(2) B) infile.read()
C) infile.readline() D) infile.readlines()
Q.9:

To read the remaining lines of the file from a file object infile, we use ____________

A) infile.read(2) B) infile.read()
C) infile.readline() D) infile.readlines()
Q.10:

The readlines() method returns ____________

A) str B) a list of lines
C) a list of single characters D) a list of integers
Q.11:

What is the correct syntax of open() function?

A) file = open(file_name [, access_mode][, buffering]) B) file object = open(file_name [, access_mode][, buffering])
C) file object = open(file_name) D) none of the mentioned
Q.12:

What is the output of this program?

fo = open("foo.txt", "wb")
print "Name of the file: ", fo.name
fo.flush()
fo.close()
fo.close()

A) Compilation Error B) Runtime Error
C) No Output D) Flushes the file when closing them
Q.13:

Correct syntax of file.writelines() is?

A) file.writelines(sequence) B) fileObject.writelines()
C) fileObject.writelines(sequence) D) none of the mentioned
Q.14:

Correct syntax of file.readlines() is?

A) fileObject.readlines( sizehint ); B) fileObject.readlines();
C) fileObject.readlines(sequence) D) none of the mentioned
Q.15:

In file handling, what does this terms means “r, a”?]

A) read, append B) append, read
C) all of the mentioned D) none of the the mentioned
Q.16:

What is the use of “w” in file handling?

A) Read B) Write
C) Append D) None of the the mentioned
Q.17:

What is the use of “a” in file handling?

A) Read B) Write
C) Append D) None of the the mentioned
Q.18:

Which function is used to read all the characters?

A) Read() B) Readcharacters()
C) Readall() D) Readchar()
Q.19:

Which function is used to read single line from file?

A) Readline() B) Readlines()
C) Readstatement() D) Readfullline()
Q.20:

Which function is used to write all the characters?

A) write() B) writecharacters()
C) writeall() D) writechar()
Q.21:

The process of pickling in Python includes:

A) conversion of a list into a datatable B) conversion of a byte stream into Python object hierarchy
C) conversion of a Python object hierarchy into byte stream D) conversion of a datatable into a list
Q.22:

To sterilize an object hierarchy, the _____________ function must be called. To desterilize a data stream, the ______________ function must be called.

A) dumps(), undumps() B) loads(), unloads()
C) loads(), dumps() D) dumps(), loads()
Q.23:

Pick the correct statement regarding pickle and marshal modules.

A) The pickle module supports primarily .pyc files whereas marshal module is used to sterilize Python objects B) The pickle module keeps track of the objects that have already been sterilized whereas the marshal module does not do this
C) The pickle module cannot be used to sterilize user defined classes and their instances whereas marshal module can be used to perform this task D) The format of sterilization of the pickle module is not guaranteed to be supported across all versions of Python. The marshal module sterilization is compatible across all the versions of Python
Q.24:

What will be the output of the following Python code?
pickle.HIGHEST_PROTOCOL

A) 4 B) 5
C) 3 D) 6
Q.25:

W Which of the following Python codes will result in an error?
object = ‘a’

A) >>> pickle.dumps(object) B) >>> pickle.dumps(object, 3)
C) >>> pickle.dumps(object, 3, True) D) >>> pickle.dumps(‘a’, 2)
Q.26:

Which of the following functions can be used to find the protocol version of the pickle module currently being used?

A) pickle.DEFAULT B) pickle.CURRENT
C) pickle.CURRENT_PROTOCOL D) pickle.DEFAULT_PROTOCOL
Q.27:

The output of the following two Python codes is exactly the same.

object
'a'
CODE 1
>>> pickle.dumps('a', 3)
CODE 2
>>> pickle.dumps(object, 3)

A) True B) False
Q.28:

Which of the following functions can accept more than one positional argument?

A) pickle.dumps B) pickle.loads
C) pickle.dump D) pickle.load
Q.29:

Which of the following functions raises an error when an unpicklable object is encountered by Pickler?

A) pickle.PickleError B) pickle.PicklingError
C) pickle.UnpickleError D) pickle.UnpicklingError
Q.30:

The pickle module defines ______ exceptions and exports _______ classes.

A) 3, 2 B) 2, 3
C) 3, 4 D) 4, 3
Q.31:

Which of the following cannot be pickled?

A) Functions which are defined at the top level of a module with lambda B) Functions which are defined at the top level of a module with def
C) Built-in functions which are defined at the top level of a module D) Classes which are defined at the top level of a module
Q.32:

If __getstate__() returns _______________ the __setstate__() module will not be called on pickling.

A) True value B) False value
C) ValueError D) OverflowError
Q.33:

Lambda functions cannot be pickled because:

A) Lambda functions only deal with binary values, that is, 0 and 1 B) Lambda functions cannot be called directly
C) Lambda functions cannot be identified by the functions of the pickle module D) All lambda functions have the same name, that is, ""
Q.34:

The module _______________ is a comparatively faster implementation of the pickle module.

A) cPickle B) nPickle
C) gPickle D) tPickle
Q.35:

The copy module uses the ___________________ protocol for shallow and deep copy.

A) pickle B) marshal
C) shelve D) copyreg
Q.36:

Config() in Python Tkinter are used for

A) destroy the widget B) place the widget
C) change property of the widget D) configure the widget
Q.37:

Correct way to draw a line in canvas tkinter ?

A) line() B) canvas.create_line()
C) create_line(canvas) D) None of the above
Q.38:

Creating line are come in which type of thing ?

A) GUI B) Canvas
C) Both of the above D) None of the above
Q.39:

Essential thing to create a window screen using tkinter python?

A) call tk() function B) create a button
C) To define a geometry D) All of the above
Q.40:

fg in tkinter widget is stands for ?

A) foreground B) background
C) forgap D) None of the above
Q.41:

For user Entry data, which widget we use in tkinter ?

A) Entry B) Text
C) Both of the above D) None of the above
Answer & Explanation
Q.42:

For what purpose, the bg is used in Tkinter widget ?

A) To change the direction of widget B) To change the size of widget
C) To change the color of widget D) To change the background of widget
Answer & Explanation
Q.43:

From which keyword we import the Tkinter in program?

A) call B) from
C) import D) All of the above
Answer & Explanation
Q.44:

GUI stands for

A) Graph user interaction B) Global user interaction
C) Graphical user interface D) Graphical user interaction
Answer & Explanation
Q.45:

How pack() function works on tkinter widget ?

A) According to x,y coordinate B) According to row and column vise
C) According to left,right,up,down D) None of the above
Answer & Explanation
Q.46:

How the grid() function put the widget on the screen ?

A) According to x,y coordinate B) According to row and column vise
C) According to left,right,up,down D) None of the above
Answer & Explanation
Q.47:

How the place() function put the widget on the screen ?

A) According to x,y coordinate B) According to row and column vise
C) According to left,right,up,down D) None of the above
Answer & Explanation
Q.48:

How we import a tkinter in python program ?

A) import tkinter B) import tkinter as t
C) from tkinter import * D) All of the above
Answer & Explanation
Q.49:

How we install tkinter in system ?

A)pip install python B) tkinter install
C) pip install tkinter D) tkinter pip install
Answer & Explanation
Q.50:

In which of the following field, we can put our Button?

A) Window B) Frame
C) Label D) All of the above
Answer & Explanation
Q.51:

It is possible to draw a circle directly in Tkinter canvas ?

A) Yes B) No
C) No(but possible by oval) D) None Of the above
Answer & Explanation
Q.52:

Minimum number of argument we pass in a function to create a rectangle using canvas tkinter ?

A) 2 B) 4
C) 6 D) 5
Answer & Explanation
Q.53:

Minimum number of argument we require to pass in a function to create a line ?

A) 2 B) 4
C) 6 D) 8
Answer & Explanation
Q.54:

Screen inside another screen is possible by creating

A) Another window B) Frames
C) Buttons D) Labels
Answer & Explanation
Q.55:

title() is used for

A) give a title name to the window B) give a title name to the Button
C) give a title name to the Widet D) None of the above
Answer & Explanation
Q.56:

Tkinter tool in python provide the

A) Database B) OS commands
C) GUI D) All of the above
Answer & Explanation
Q.57:

To change the color of the text in the Button widget, what we use ?

A) bg B) fg
C) color D) cchng
Answer & Explanation
Q.58:

To change the property of the widget after the declaration of widget, what e use ?

A) mainloop() function B) config() function
C) pack() function D) title() function
Answer & Explanation
Q.59:

To delete any widget from the screen which function we use ?

A) stop() B) delete()
C) destroy() D) break()
Answer & Explanation
Q.60:

To get the multiple line user data, which widget we use ?

A) Entry B) Text
C) Both of the above D) None of the above
Answer & Explanation
Q.61:

To hold the screen what we use ?

A) mainloop() function B) pause() function
C) Stop() function D) None of the above
Answer & Explanation
Q.62:

use of the angle attribute are on which widget ?

A) line B) text
C) Button D) All of the above
Answer & Explanation
Q.63:

What is the correct syntax of destroy in tkinter ?

A) destroy(object) B) object.destroy()
C) object(destroy) D) delete(object)
Answer & Explanation
Q.64:

What is the correct way to use the config() function in tkinter ?

A) config(object,property) B) object.config(property)
C) config(property) D) object.property
Answer & Explanation
Q.65:

What is the right way to set the title of the window ?

A) title(win,mytitle) B) win.title(mytitle)
C) title(mytitle).win D) None of the above
Answer & Explanation
Q.66:

What is the Syntax to create a Frame ?

A) Frame(window,options) B) win.frame(options)
C) Both of the above D) None of the above
Answer & Explanation
Q.67:

What is the use of the Entry widget in tkinter python ?

A) Display text on the window B) Display Check button on window
C) Create a user data entry field D) All of the above
Answer & Explanation
Q.68:

What is the use of the mainloop() in Python Tkinter ?

A) To create a window screen B) To Destroy the window screen
C) To Hold the window Screen D) None of the above
Answer & Explanation
Q.69:

What is the use of the pack() function for the tkinter widget ?

A) To pack the widget on the screen B) To define a size of the widget
C) To perform a task by a widget D) To destroy the widget
Answer & Explanation
Q.70:

What is the use of the place() function in tkinter Python ?

A) To put the widget on the screen B) To put the widget on the Button
C) To put the widget on the background D) To destroy the widget
Answer & Explanation
Q.71:

what is Tk() in tkinter python ?

A) It is function B) It is constructor
C) It is widget D) All of the above
Answer & Explanation
Q.72:

What is widget in Tkinter GUI in python

A) That will display on the screen B) That will work in background
C) Both of the above D) None of the above
Answer & Explanation
Q.73:

What we use to change the back ground color any widget ?

A) background B) fg
C) bg D) bground
Answer & Explanation
Q.74:

Which of th following is used to call a function by the Button widget in tkinter python ?

A) call B) cammand
C) contact D) All of the above
Answer & Explanation
Q.75:

Which of the correct way to set the geometry of the window ?

A) geometry(x,y) B) geometry(300x400)
C) geometry(300,400) D) None of the above
Answer & Explanation
Q.76:

Which of the following command are used to install the tkinter ?

A) pip install Tkinter B) pip install python tkinter
C) pip install tkinter python D) None of the above
Answer & Explanation
Q.77:

Which of the following function are used to get the data from the Entry field in Python Tkinter ?

A) get() B) Gettext()
C) Getdata() D) All of the above
Answer & Explanation
Q.78:

Which of the following is clickable in GUI programming ?

A) Button B) Checkbutton
C) Lable D) 1 and 2
Answer & Explanation
Q.79:

Which of the following is correct ?

A) GUI is the part of the canvas B) canvas is the part of the GUI
C) Both of the above D) None of the above
Answer & Explanation
Q.80:

Which of the following is not correct way to import the tkinter in program ?

A) import tkinter from * B) import tkinter as t
C) import tkinter as p D) All of the above
Answer & Explanation
Q.81:

Which of the following is used to put the widget at the screen ?

A) pack() B) place()
C) grid() D) All of the above
Answer & Explanation
Q.82:

Which of the following tool provides a GUI in python

A) Numpy B) Tkinter
C) Scipy D) Opencv
Answer & Explanation
Q.83:

Which of the following we can able to delete using destroy() function ?

A) Button B) Label
C) Frame D) All of the above
Answer & Explanation
Q.84:

Which of the following we can draw using canvas in tkinter ?

A) Line B) Rectangle
C) oval D) All of the above
Answer & Explanation
Q.85:

Which widget are used to get the data from the user ?

A) Button B) Label
C) Entry D) None of the above
Answer & Explanation
Q.86:

Which of the following is used to access the database server at the time of executing the program and get the data from the server accordingly?

A) Embedded SQL B) Dynamic SQL
C) SQL declarations D) SQL data analysis
Q.87:

Which of the following header must be included in java program to establish database connectivity using JDBC ?

A) Import java.sql.*; B) Import java.sql.odbc.jdbc.*;
C) Import java.jdbc.*; D) Import java.sql.jdbc.*;
Q.88:

DriverManager.getConnection(_______ , ______ , ______)
What are the two parameters that are included?

A) URL or machine name where server runs, Password, User ID B) URL or machine name where server runs, User ID, Password
C) User ID, Password, URL or machine name where server runs D) Password, URL or machine name where server runs, User ID
Q.89:

Which of the following invokes functions in sql?

A) Prepared Statements B) Connection statement
C) Callable statements D) All of the mentioned
Q.90:

Which of the following function is used to find the column count of the particular resultset?

A) getMetaData() B) Metadata()
C) getColumn() D) get Count()
Q.1:

The plot method on Series and DataFrame is just a simple wrapper around ____________

A) gplt.plot() B) plt.plot()
C) plt.plotgraph() D) none of the mentioned
Q.2:

Point out the correct combination with regards to kind keyword for graph plotting.

A) ‘hist’ for histogram B) ‘box’ for boxplot
C) ‘area’ for area plots D) all of the mentioned
Q.3:

Which of the following value is provided by kind keyword for barplot?

A) bar B) kde
C) hexbin D) none of the mentioned
Q.4:

You can create a scatter plot matrix using the __________ method in pandas.tools.plotting.

A) sca_matrix B) scatter_matrix
C) DataFrame.plot D) All of the mentioned
Q.5:

Point out the wrong combination with regards to kind keyword for graph plotting.

A) ‘scatter’ for scatter plots B) ‘kde’ for hexagonal bin plots
C) ‘pie’ for pie plots D) none of the mentioned
Q.6:

Which of the following plots are used to check if a data set or time series is random?

A) Lag B) Random
C) Lead D) None of the mentioned
Q.7:

Plots may also be adorned with error bars or tables.

A) True B) False
Q.8:

Which of the following plots are often used for checking randomness in time series?

A) Autocausation B) Autorank
C) Autocorrelation D) None of the mentioned
Q.9:

__________ plots are used to visually assess the uncertainty of a statistic.

A) Lag B) RadViz
C) Bootstrap D) None of the mentioned
Q.10:

Andrews curves allow one to plot multivariate data.

A) True B) False
Q.11:

Which is a python package used for 2D graphics?

A) matplotlib.pyplot B) matplotlib.pip
C) matplotlib.numpy D) matplotlib.plt
Q.12:

Identify the package manager for Python packages, or modules.

A) Matplotlib B) PIP
C) plt.show() D) python package
Q.13:

Read the following code: Identify the purpose of this code and choose the right option from the following.
C:\Users\YourName\AppData\Local\Programs\Python\Python36-32\Scripts>pip – version

A) Check if PIP is Installed B) Install PIP
C) Download a Package D) Check PIP version
Q.14:

Read the following code: Identify the purpose of this code and choose the right option from the following.
C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip list

A) List installed packages B) list command
C) Install PIP D) packages installed
Q.15:

To install matplotlib, the following function will be typed in your command prompt. What does “-U”represents?
Python –m pip install –U pip

A) downloading pip to the latest version B) upgrading pip to the latest version
C) removing pip D) upgrading matplotlib to the latest version
Q.16:

Which key is used to run the module?

A) F6 B) F4
C) F3 D) F5
Q.17:

Identify the right type of chart using the following hints.
Hint 1: This chart is often used to visualize a trend in data over intervals of time.
Hint 2: The line in this type of chart is often drawn chronologically.

A) Line chart B) Bar chart
C) Pie chart D) Scatter plot
Q.18:

Read the statements given below. Identify the right option from the following for pie chart.
Statement A: To make a pie chart with Matplotlib, we can use the plt.pie() function.
Statement B: The autopct parameter allows us to display the percentage value using the Python string formatting.

A) Statement A is correct B) Statement B is correct
C) Both the statements are correct D) Both the statements are wrong
Q.19:

Which function is used to read single line from file?

A) Readline() B) Readlines()
C) Readstatement() D) Readfullline()
Q.20:

Which function is used to write all the characters?

A) write() B) writecharacters()
C) writeall() D) writechar()
Q.21:

Pandas is an open-source _______ Library?

A) Ruby B) Javascript
C) Java D) Python
Q.22:

Pandas key data structure is called?

A) Keyframe B) DataFrame
C) Statistics D) Econometrics
Q.23:

In pandas, Index values must be?

A) unique B) hashable
C) Both A and B D) None of the above
Q.24:

Which of the following is correct Features of DataFrame?

A) Potentially columns are of different types B) Can Perform Arithmetic operations on rows and columns
C) Labeled axes (rows and columns) D) All of the above
Q.25:

A panel is a ___ container of data

A) 1D B) 2D
C) 3D D) Infinite
Q.26:

Which of the following is true?

A) If data is an ndarray, index must be the same length as data. B) Series is a one-dimensional labeled array capable of holding any data type.
C) Both A and B D) None of the above
Q.27:

Which of the following takes a dict of dicts or a dict of array-like sequences and returns a DataFrame?

A) DataFrame.from_items B) DataFrame.from_records
C) DataFrame.from_dict D) All of the above
Q.28:

Which of the following makes use of pandas and returns data in a series or dataFrame?

A) pandaSDMX B) freedapi
C) OutPy D) Inpy
Q.29:

What will be output for the following code?
import pandas as pd
import numpy as np
s = pd.Series(np.random.randn(4))
print s.ndim

A) 0 B) 1
C) 2 D) 3
Q.30:

Which of the following indexing capabilities is used as a concise means of selecting data from a pandas object?

A) In B) ix
C) ipy D) iy
Q.31:

Which of the following thing can be data in Pandas?

A) a python dict B) an ndarray
C) a scalar value D) all of the mentioned
Q.32:

Point out the correct statement.

A) If data is a list, if index is passed the values in data corresponding to the labels in the index will be pulled out B) NaN is the standard missing data marker used in pandas
C) Series acts very similarly to a array D) None of the mentioned
Q.33:

The result of an operation between unaligned Series will have the ________ of the indexes involved.

A) intersection B) union
C) total D) All of the mentioned
Q.34:

Which of the following input can be accepted by DataFrame?

A) Structured ndarray B) Series
C) DataFrame D) All of the mentioned
Q.35:

Point out the wrong statement.

A) A DataFrame is like a fixed-size dict in that you can get and set values by index label B) Series can be be passed into most NumPy methods expecting an ndarray
C) A key difference between Series and ndarray is that operations between Series automatically align the data based on label D) None of the mentioned
Q.36:

Which of the following takes a dict of dicts or a dict of array-like sequences and returns a DataFrame?

A) DataFrame.from_items B) DataFrame.from_records
C) DataFrame.from_dict D) All of the mentioned
Q.37:

Series is a one-dimensional labeled array capable of holding any data type.

A) True B) False
Q.38:

Which of the following works analogously to the form of the dict constructor?

A) DataFrame.from_items B) DataFrame.from_records
C) DataFrame.from_dict D) All of the mentioned
Q.39:

Which of the following operation works with the same syntax as the analogous dict operations?

A) Getting columns B) Setting columns
C) Deleting columns D) All of the mentioned
Q.40:

If data is an ndarray, index must be the same length as data.

A) True B) False
Q.41:

Best way to import the pandas module in your program ?

A) import pandas B) import pandas as p
C) from pandas import * D) All of the above
Answer & Explanation
Q.42:

DataFrame in pandas is

A) 1 dimensional array B) 2 dimensional array
C) 3 dimensional array D) None of the above
Answer & Explanation
Q.43:

For what purpose a Pandas is used ?

A) To create a GUI programming B) To create a database
C) To create a High level array D) All of the above
Answer & Explanation
Q.44:

In data science, which of the python library are more popular ?

A) Numpy B) Pandas
C) OpenCv D) Django
Answer & Explanation
Q.45:

Minimum number of argument we require to pass in pandas series ?

A) 0 B) 1
C) A2 D) 3
Answer & Explanation
Q.46:

Series in Pandas is

A) 1 dimensional array B) 2 dimensional array
C) 3 dimensional array D) None of the above
Answer & Explanation
Q.47:

Way to install the pandas library ?

A) install pandas B) pandas install python
C) python install pandas D) None of the above
Answer & Explanation
Q.48:

we can analyze the data in pandas with :

A) Series B) DataFrame
C) Both of the above D) None of the above
Answer & Explanation
Q.49:

What we pass in DataFrame in pandas ?

A)Integer B) String
C) Pandas series D) All of the above
Answer & Explanation
Q.50:

In which of the following field, we can put our Button?

A) Window B) Frame
C) Label D) All of the above
Answer & Explanation
Q.51:

SciPy stands for?

A) science library B) source library
C) significant library D) scientific library
Answer & Explanation
Q.52:

Which of the following is not correct sub-packages of SciPy?

A) scipy.cluster B) scipy.source
C) scipy.interpolate D) scipy.signal
Answer & Explanation
Q.53:

Which of the following is true?

A) By default, all the NumPy functions have been available through the SciPy namespace B) There is no need to import the NumPy functions explicitly, when SciPy is imported.
C) SciPy is built on top of NumPy arrays D) All of the above
Answer & Explanation
Q.54:

What will be output for the following code?
import numpy as np
print np.linspace(1., 4., 6)

A) array([ 1. , 2.2, 2.8, 3.4, 4. ]) B) array([ 1. , 1.6, 2.8, 3.4, 4. ])
C) array([ 1. , 1.6, 2.2, 2.8, 3.4, 4. ]) D) array([ 1. , 1.6, 2.2, 2.8, 4. ])
Answer & Explanation
Q.55:

How to import Constants Package in SciPy?

A) import scipy.constants B) from scipy.constants
C) import scipy.constants.package D) from scipy.constants.package
Answer & Explanation
Q.56:

what is constant defined for Boltzmann constant in SciPy?

A) G B) e
C) R D) k
Answer & Explanation
Q.57:

What will be output for the following code?
from scipy import linalg
import numpy as np
a = np.array([[3, 2, 0], [1, -1, 0], [0, 5, 1]])
b = np.array([2, 4, -1])
x = linalg.solve(a, b)
print x

A) array([ 2., -2., 9., 6.]) B) array([ 2., -2., 9.])
C) array([ 2., -2.]) D) array([ 2., -2., 9., -9.])
Answer & Explanation
Q.58:

In SciPy, determinant is computed using?

A) determinant() B) SciPy.determinant()
C) det() D) SciPy.det()
Answer & Explanation
Q.59:

Which of the following is false?

A) scipy.linalg also has some other advanced functions that are not in numpy.linalg B) SciPy version might be faster depending on how NumPy was installed.
C) Both A and B D) None of the above
Answer & Explanation
Q.60:

What relation is consider between Eigen value (lambda), square matrix (A) and Eign vector(v)?

A) Av = lambda*v B) Av =Constant * lambda*v
C) Av =10 * lambda*v D) Av != lambda*v
Answer & Explanation
Q.61:

Flask is a web development framework created in ___________ language.

A) C B) Java
C) Python D) Javascript
Answer & Explanation
Q.62:

Is the Flask framework open source?

A) TRUE B) FALSE
C) Can be true or false D) Can not say
Answer & Explanation
Q.63:

It is released under the ___________ Clause.

A) BSD-0 B) BSD-1
C) BSD-2 D) BSD-3
Answer & Explanation
Q.64:

How to add the mailing feature in the Flask Application?

A) pip install Flask B) pip install Flask-Mail
C) install Flask-Mail D) pip Flask-Mail
Answer & Explanation
Q.65:

WSGI stands for the?

A) Write Server Gateway Interface B) Web Static Gateway Interface
C) Web Server Gateway Interface D) Web Server Gateway Interact
Answer & Explanation
Q.66:

Flask default port is?

A) 2000 B) 3000
C) 4000 D) 5000
Answer & Explanation
Q.67:

Flask default host is a localhost (127.0.0.1)

A) TRUE B) FALSE
C) Can be true or false D) Can not say
Answer & Explanation
Q.68:

Flask is called a?

A) miniframework B) microframework
C) peraframework D) nanoframework
Answer & Explanation
Q.69:

Which of the following are the benefits of using the Flask framework?

A) It has an inbuilt development server. B) It has vast third-party extensions.
C) It is WSGI compliant. D) All of the above
Answer & Explanation
Q.70:

Flask works with most of the RDBMSs, such as?

A) PostgreSQL B) SQLite
C) MySQL D) All of the above
Answer & Explanation
Q.1:

How many except statements can a try-except block have?

A) zero B) one
C) more than one D) more than zero
Answer & Explanation
Q.2:

When will the else part of try-except-else be executed?

A) always B) when an exception occurs
C) when no exception occurs D) when an exception occurs in to except block
Answer & Explanation
Q.3:

Is the following Python code valid?

try:
  # Do something
except:
  # Do something
finally:
  # Do something

A) no, there is no such thing as finally B) no, finally cannot be used with except
C) o, finally must come before except D) yes
Answer & Explanation
Q.4:

Is the following Python code valid?

try:
  # Do something
except:
  # Do something
else :
  # Do something

A) no, there is no such thing as else B) no, else cannot be used with except
C) o, else must come before except D) yes
Answer & Explanation
Q.5:

Can one block of except statements handle multiple exception?

A) yes, like except TypeError, SyntaxError [,…] B) yes, like except [TypeError, SyntaxError]
C) no D) none of the mentioned
Answer & Explanation
Q.6:

When is the finally block executed?

A) when there is no exception B) when there is an exception
C) only if some condition that has been specified is satisfied D) always
Answer & Explanation
Q.7:

What will be the output of the following Python code?

def foo():
 try:
  return 1;
 finally:
  return 2
k = foo()
print(k)

A) 1 B) 2
C) 3 D) error, there is more than one return statement in a single try-finally block
Answer & Explanation
Q.8:

What will be the output of the following Python code?

def foo():
  try:
   print(1)   finally:
   print(2)
foo()

A) 1 2 B) 1
C) 2 D) none of the mentioned
Answer & Explanation
Q.9:

What will be the output of the following Python code?

try:
  if '1' != 1:    raise "someError"
 else:
    print("someError has not occurred") except "someError":
 print ("someError has occurred")

A) Rs. someError has occurred B) someError has not occurred
C) invalid code D) none of the mentioned
Answer & Explanation
Q.10:

What happens when ‘1’ == 1 is executed?

A) we get a True B) we get a False
C) an TypeError occurs D) a ValueError occurs
Answer & Explanation
Q.11:

Which of these definitions correctly describes a module?

A) Denoted by triple quotes for providing the specification of certain program elements B) Design and implementation of specific functionality to be incorporated into a program
C) Defines the specification of how it is to be used D) Any program that reuses code
Answer & Explanation
Q.12:

Which of the following is not an advantage of using modules?

A) Provides a means of reuse of program code B) Provides a means of dividing up tasks
C) Provides a means of reducing the size of the program D) Provides a means of testing individual parts of the program
Answer & Explanation
Q.13:

Program code making use of a given module is called a ______ of the module.

A) Client B) Docstring
C) Interface D) Modularity
Answer & Explanation
Q.14:

______ is a string literal denoted by triple quotes for providing the specifications of certain program elements.

A) Interface B) Modularity
C) Client D) Docstring
Answer & Explanation
Q.15:

Which of the following is true about top-down design process?

A) The details of a program design are addressed before the overall design B) Only the details of the program are addressed
C) The overall design of the program is addressed before the details D) Only the design of the program is addressed
Answer & Explanation
Q.16:

In top-down design every module is broken into same number of submodules.

A) True B) False
Answer & Explanation
Q.17:

All modular designs are because of a top-down design process.

A) True B) False
Answer & Explanation
Q.18:

What will be the output of the following Python code?

#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]
C) [2,4,6]
[1,4,9]
D) There is a name clash
Answer & Explanation
Q.19:

Which of the following isn’t true about main modules?

A) When a python file is directly executed, it is considered main module of a program B) Main modules may import any number of modules
C) Special name given to main modules is: __main__ D) Other main modules can import main modules
Answer & Explanation
Q.20:

Which of the following is not a valid namespace?

A) Global namespace B) Public namespace
C) Built-in namespace D) Local namespace
Answer & Explanation
Q.21:

Which of the following is false about “import modulename” form of import?

A) zero B) This form of import prevents name clash
C) The namespace of imported module becomes available to importing module D) The identifiers in module are accessed as: modulename.identifier
Answer & Explanation
Q.22:

Which of the following is false about “from-import” form of import?

A) The syntax is: from modulename import identifier B) This form of import prevents name clash
C) The namespace of imported module becomes part of importing module D) The identifiers in module are accessed directly as: identifier
Answer & Explanation
Q.23:

Which of the statements about modules is false?

A) In the “from-import” form of import, identifiers beginning with two underscores are private and aren’t imported B) dir() built-in function monitors the items in the namespace of the main module
C) In the “from-import” form of import, all identifiers regardless of whether they are private or public are imported D) When a module is loaded, a compiled version of the module with file extension .pyc is automatically produced
Answer & Explanation
Q.24:

What will be the output of the following Python code?

try:
from math import factorial
print(math.factorial(5))

A) 120 B) Nothing is printed
C) Error, method factorial doesn’t exist in math module D) Error, the statement should be: print(factorial(5))
Answer & Explanation
Q.25:

Can one block of except statements handle multiple exception?

A) Python first searches the global namespace, then the local namespace and finally the built-in namespace B) Python first searches the local namespace, then the global namespace and finally the built-in namespace
C) Python first searches the built-in namespace, then the global namespace and finally the local namespace D) Python first searches the built-in namespace, then the local namespace and finally the global namespace
Answer & Explanation
Q.26:

What does math.sqrt(X, Y) do ??

A) calculate the Xth root of Y B) calculate the Yth root of X
C) error D) return a tuple with the square root of X and Y
Answer & Explanation
Q.27:

Which block lets you test a block of code for errors?

A) try B) except
C) finally D) None of the above
Answer & Explanation
Q.28:

What will be the output of the following Python code?

try:
  print(x)
except:
 print(""An exception occurred"")

A) X B) An exception occurred
C) Error D) None of the above
Answer & Explanation
Q.29:

What will be the output of the following Python code?

x = ""hello""

if not type(x) is int:
  raise TypeError(""Only integers are allowed"")

A) hello B) garbage value
C) Only integers are allowed D) Error
Answer & Explanation
Q.30:

What will be output for the folllowing code?

try:
 f = open(""demofile.txt"")
  f.write(""Lorum Ipsum"")
except:
  print(""Something went wrong when writing to the file"")
finally:
  f.close()

A) demofile.txt B) Lorum Ipsum
C) Garbage value D) Something went wrong when writing to the file
Answer & Explanation
Q.31:

Which exception raised when a calculation exceeds maximum limit for a numeric type?

A) StandardError B) ArithmeticError
C) OverflowError D) FloatingPointError
Answer & Explanation
Q.32:

Which exception raised in case of failure of attribute reference or assignment?

A) AttributeError B) EOFError
C) ImportError D) AssertionError
Answer & Explanation
Q.33:

How many except statements can a try-except block have?

A) 0 B) 1
C) more than one D) more than zero
Answer & Explanation
Q.34:

Can one block of except statements handle multiple exception?

A) yes, like except TypeError, SyntaxError [,…] B) yes, like except [TypeError, SyntaxError]
C) No D) None of the above
Answer & Explanation
Q.35:

The following Python code will result in an error if the input value is entered as -5.

A) TRUE B) FASLE
C) Can be true or false D) Can not say
Answer & Explanation
Q.36:

What will be output for the folllowing code?

x=10
y=8
assert x>y, 'X too small

A) Assertion Error B) 10 8
C) No output D) 108
Answer & Explanation
Q.37:

what is math.floor(0o10) ??

A) 8 B) 10
A) 0 B) 9
Answer & Explanation
Q.38:

What is returned by math.modf(1,0)?

+

A) (0.0,1.0) B) (1.0,0,0.0)
C) (0.5,1)
[1,4,9]
D) (0.5,1.0)
Answer & Explanation
Q.39:

what is the value of x if x = math.sqrt(4)

A) 2 B) 2.0
C) (2,-2) D) (2.0,2.0)
Answer & Explanation
Q.40:

what will be the output of print(math.factorial(4,5))??

A) 24 B) 120
C) error D) 24.0
Answer & Explanation
Q.41:

what is the value of X if x = math.idexp(0,5,1)??

A) 1 B) 2.0
C) 0.5 D) none of the mentioned
Answer & Explanation
Q.42:

what is the output of print(math.pow(3,2))??

A) 9 B) 9.0
C) None D) none of the mentioned
Answer & Explanation
Q.43:

what is math.factorial(4,0)??

A) 24 B) 1
C) error D) none of the mentioned
Answer & Explanation
Q.44:

what will be the output ?? print(math.isinf(float('inf')))??

A) error, the minus sign shouldn't have been inside the brackets B) error, there is no function called itself
C) True D) False
Answer & Explanation
Q.45:

what is returned by int(math.pow(3,2))??

A) 6 B) 9
C) error,third argument requires D) error, too many arguments
Answer & Explanation