Is Python case sensitive when dealing with identifiers?
A) Yes | B) No |
C) Machine dependent | D) None of the mentioned |
Is Python case sensitive when dealing with identifiers?
A) Yes | B) No |
C) Machine dependent | D) None of the mentioned |
What is the maximum possible length of an identifier?
A) 31 characters | B) 63 characters |
C) 79 characters | D) None of the mentioned |
Which of the following is invalid?
A) _a = 1 | B) __a = 1 |
C) __str__ = 1 | D) None of the mentioned |
Which of the following is an invalid variable?
A) my_string_1 | B) 1st_string |
C) foo | D) _ |
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 |
Which of the following is not a keyword?
A) eval | B) assert |
C) nonlocal | D) pass |
All keywords in Python are in _________
A) lower case | B) UPPER CASE |
C) Capitalized | D) None of the mentioned |
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 |
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 |
Which of the following cannot be a variable?
A) __init__ | B) in |
C) it | D) on |
Which is the correct operator for power(xy)?
A) X^y | B) X**y |
C) X^^y | D) None of the mentioned |
Which one of these is floor division?
A) / | B) // |
C) % | D) None of the mentioned |
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 |
What is the answer to this expression, 22 % 3 is?
A) 7 | B) 1 |
C) 0 | D) 5 |
Mathematical operations can be performed on a string.
A) True | B) False |
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 |
What is the output of this expression, 3*1**3 ?
A) 27 | B) 9 |
C) 3 | D) 1 |
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 |
The expression Int(x) implies that the variable x is converted to integer.
A) True | B) False |
Which one of the following has the highest precedence in the expression?
A) Exponential | B) Addition |
C) Multiplication | D) Parentheses |
What is the output of print 0.1 + 0.2 == 0.3?
A) True | B) False |
C) Machine dependent | D) Error |
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 |
What is the type of inf ?
A) Boolean | B) Integer |
C) Float | D) Complex |
What does ~4 evaluate to ?
A) -5 | B) -4 |
C) -3 | D) +3 |
What does ~~~~~~5 evaluate to?
A) +5 | B) -11 |
C) +11 | D) -5 |
Which of the following is incorrect?
A) x = 0b101 | B) x = 0x4f5 |
C) x = 19023 | D) x = 03964 |
What is the result of cmp(3, 1)?
A) 1 | B) 0 |
C) True | D) False |
Which of the following is incorrect?
A) float(‘inf’) | B) float(‘nan’) |
C) float(’56’+’78’) | D) float(’12+34′) |
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 |
What does 3 ^ 4 evaluate to ?
A) 81 | B) 12 |
C) 0.75 | D) 7 |
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 |
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 |
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 |
What will be the output of statement 2**2**2**2
A) 16 | B) 256 |
C) 32768 | D) 65536 |
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. |
What is the output of the following code: print 9//2
A) 4 | B) 4.5 |
C) 4.0 | D) Error |
Which of the following is not a valid variable name in Python?
A) _var | B) var_name |
C) var11 | D) 5var |
What is the maximum length of an identifier in python?
A) 32 | B) 31 |
C) 63 | D) None of the above |
Which of the following declarations is incorrect?
A) None Of the below | B) _x = 2 |
C) __x = 3 | D) __xyz__ = 5 |
What is the result of round(0.5) – round(-0.5)?
A) 1.0 | B) 2.0 |
C) 0 | D) None Of the above |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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. |
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 |
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 |
for i in range(-3), how many times this loop will run ?
A) 0 | B) 1 |
C) Infinite | D) Error |
for i in [1,2,3]:, how many times a loop run ?
A) 0 | B) 1 |
C) 2 | D) 3 |
for loop in python are work on
A) range | B) iteration |
C) Both of the above | D) None of the above |
How many times it will print the statement ?, for i in range(100): print(i)
A) 101 | B) 99 |
C) 100 | D) 0 |
For loop in python is
A) Entry control loop | B) Exit control loop |
C) Simple loop | D) None of the above |
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 |
It is possible to create a loop using goto statement in python ?
A) Yes | B) No |
C) Sometimes | D) None of the above |
To break the infinite loop , which keyword we use ?
A) continue | B) break |
C) exit | D) None of the above |
l=[],for i in l: print(l), what is the output ?
A) [] | B) list |
C) print() | D) None of the above |
What is the final value of the i after this, for i in range(3): pass
A) 1 | B) 2 |
C) 3 | D) 0 |
What is the value of i after the for loop ?, for i in range(4):break
A) 0 | B) 1 |
C) 3 | D) 2 |
What we put at the last of the loop ?
A) semicolon | B) colon |
C) comma | D) None of the above |
which of the following is consider as a infinite loop
A) while(infinte): | B) while(1): |
C) for(1): | D) None of the above |
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 |
Which of the following is the loop in python ?
A)for | B) while |
C) do while | D) 1 and 2 |
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 |
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 |
While(0), how many times a loop run ?
A) 0 | B) 1 |
C) 3 | D) infinite |
while(1): print(2), How many times a loops run ?
A) 1 | B) 2 |
C) 3 | D) None of the above |
while(1==3):, how many times a loop run ?
A) 1 | B) infinite |
C) 3 | D) 0 |
Which of the following would give an error?
A) list1=[] | B) list1=[]*3 |
C) list1=[2,8,7] | D) None of the above |
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. |
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] |
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]) |
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)) |
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 |
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 |
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] |
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 |
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 |
Which of the following is a Python tuple ?
A) [1, 2, 3] | B) (1, 2, 3) |
C) {1, 2, 3} | D) {} |
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)) |
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) |
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) |
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) |
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” |
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] |
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 |
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 |
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 |
Which of the following statements is used to create an empty set?
A) { } | B) set() |
C) [ ]. | D) ( ) |
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} |
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} |
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 |
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 |
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 |
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} |
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 |
Set members must not be hashable.
A) True | B) False |
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 |
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 |
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} |
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 |
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 |
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}) |
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} |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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) |
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 |
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 |
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 |
True or false? Python treats the words “Exciting” and “exciting” as the same word.
A)True | B) False |
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 |
NumPY stands for?
A) Numbering Python | B) Number In Python |
C) Numerical Python | D) None Of the above |
NumPy is often used along with packages like?
A) Node.js | B) Matplotlib |
C) SciPy | D) Both B and C |
The most important object defined in NumPy is an N-dimensional array type called?
A) ndarray | B) narray |
C) nd_array | D) darray |
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 |
What will be output for the following code?
import numpy as np
a = np.array([1, 2, 3], dtype = complex)
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] |
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 |
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 |
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) |
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 |
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 |
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 |
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 |
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 |
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] |
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 |
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] |
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 |
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 |
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 |
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 |
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”) |
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”) |
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”) |
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 |
To read two characters from a file object infile, we use ____________
A) infile.read(2) | B) infile.read() |
C) infile.readline() | D) infile.readlines() |
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() |
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 |
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() |
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() |
The readlines() method returns ____________
A) str | B) a list of lines |
C) a list of single characters | D) a list of integers |
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 |
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 |
Correct syntax of file.writelines() is?
A) file.writelines(sequence) | B) fileObject.writelines() |
C) fileObject.writelines(sequence) | D) none of the mentioned |
Correct syntax of file.readlines() is?
A) fileObject.readlines( sizehint ); | B) fileObject.readlines(); |
C) fileObject.readlines(sequence) | D) none of the mentioned |
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 |
What is the use of “w” in file handling?
A) Read | B) Write |
C) Append | D) None of the the mentioned |
What is the use of “a” in file handling?
A) Read | B) Write |
C) Append | D) None of the the mentioned |
Which function is used to read all the characters?
A) Read() | B) Readcharacters() |
C) Readall() | D) Readchar() |
Which function is used to read single line from file?
A) Readline() | B) Readlines() |
C) Readstatement() | D) Readfullline() |
Which function is used to write all the characters?
A) write() | B) writecharacters() |
C) writeall() | D) writechar() |
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 |
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() |
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 |
What will be the output of the following Python code?
pickle.HIGHEST_PROTOCOL
A) 4 | B) 5 |
C) 3 | D) 6 |
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) |
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 |
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 |
Which of the following functions can accept more than one positional argument?
A) pickle.dumps | B) pickle.loads |
C) pickle.dump | D) pickle.load |
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 |
The pickle module defines ______ exceptions and exports _______ classes.
A) 3, 2 | B) 2, 3 |
C) 3, 4 | D) 4, 3 |
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 |
If __getstate__() returns _______________ the __setstate__() module will not be called on pickling.
A) True value | B) False value |
C) ValueError | D) OverflowError |
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, " |
The module _______________ is a comparatively faster implementation of the pickle module.
A) cPickle | B) nPickle |
C) gPickle | D) tPickle |
The copy module uses the ___________________ protocol for shallow and deep copy.
A) pickle | B) marshal |
C) shelve | D) copyreg |
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 |
Correct way to draw a line in canvas tkinter ?
A) line() | B) canvas.create_line() |
C) create_line(canvas) | D) None of the above |
Creating line are come in which type of thing ?
A) GUI | B) Canvas |
C) Both of the above | D) None of the above |
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 |
fg in tkinter widget is stands for ?
A) foreground | B) background |
C) forgap | D) None of the above |
For user Entry data, which widget we use in tkinter ?
A) Entry | B) Text |
C) Both of the above | D) None of the above |
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 |
From which keyword we import the Tkinter in program?
A) call | B) from |
C) import | D) All of the above |
GUI stands for
A) Graph user interaction | B) Global user interaction |
C) Graphical user interface | D) Graphical user interaction |
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 |
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 |
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 |
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 |
How we install tkinter in system ?
A)pip install python | B) tkinter install |
C) pip install tkinter | D) tkinter pip install |
In which of the following field, we can put our Button?
A) Window | B) Frame |
C) Label | D) All of the above |
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 |
Minimum number of argument we pass in a function to create a rectangle using canvas tkinter ?
A) 2 | B) 4 |
C) 6 | D) 5 |
Minimum number of argument we require to pass in a function to create a line ?
A) 2 | B) 4 |
C) 6 | D) 8 |
Screen inside another screen is possible by creating
A) Another window | B) Frames |
C) Buttons | D) Labels |
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 |
Tkinter tool in python provide the
A) Database | B) OS commands |
C) GUI | D) All of the above |
To change the color of the text in the Button widget, what we use ?
A) bg | B) fg |
C) color | D) cchng |
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 |
To delete any widget from the screen which function we use ?
A) stop() | B) delete() |
C) destroy() | D) break() |
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 |
To hold the screen what we use ?
A) mainloop() function | B) pause() function |
C) Stop() function | D) None of the above |
use of the angle attribute are on which widget ?
A) line | B) text |
C) Button | D) All of the above |
What is the correct syntax of destroy in tkinter ?
A) destroy(object) | B) object.destroy() |
C) object(destroy) | D) delete(object) |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
what is Tk() in tkinter python ?
A) It is function | B) It is constructor |
C) It is widget | D) All of the above |
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 |
What we use to change the back ground color any widget ?
A) background | B) fg |
C) bg | D) bground |
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 |
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 |
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 |
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 |
Which of the following is clickable in GUI programming ?
A) Button | B) Checkbutton |
C) Lable | D) 1 and 2 |
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 |
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 |
Which of the following is used to put the widget at the screen ?
A) pack() | B) place() |
C) grid() | D) All of the above |
Which of the following tool provides a GUI in python
A) Numpy | B) Tkinter |
C) Scipy | D) Opencv |
Which of the following we can able to delete using destroy() function ?
A) Button | B) Label |
C) Frame | D) All of the above |
Which of the following we can draw using canvas in tkinter ?
A) Line | B) Rectangle |
C) oval | D) All of the above |
Which widget are used to get the data from the user ?
A) Button | B) Label |
C) Entry | D) None of the above |
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 |
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.*; |
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 |
Which of the following invokes functions in sql?
A) Prepared Statements | B) Connection statement |
C) Callable statements | D) All of the mentioned |
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() |
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 |
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 |
Which of the following value is provided by kind keyword for barplot?
A) bar | B) kde |
C) hexbin | D) none of the mentioned |
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 |
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 |
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 |
Plots may also be adorned with error bars or tables.
A) True | B) False |
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 |
__________ plots are used to visually assess the uncertainty of a statistic.
A) Lag | B) RadViz |
C) Bootstrap | D) None of the mentioned |
Andrews curves allow one to plot multivariate data.
A) True | B) False |
Which is a python package used for 2D graphics?
A) matplotlib.pyplot | B) matplotlib.pip |
C) matplotlib.numpy | D) matplotlib.plt |
Identify the package manager for Python packages, or modules.
A) Matplotlib | B) PIP |
C) plt.show() | D) python package |
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 |
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 |
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 |
Which key is used to run the module?
A) F6 | B) F4 |
C) F3 | D) F5 |
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 |
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 |
Which function is used to read single line from file?
A) Readline() | B) Readlines() |
C) Readstatement() | D) Readfullline() |
Which function is used to write all the characters?
A) write() | B) writecharacters() |
C) writeall() | D) writechar() |
Pandas is an open-source _______ Library?
A) Ruby | B) Javascript |
C) Java | D) Python |
Pandas key data structure is called?
A) Keyframe | B) DataFrame |
C) Statistics | D) Econometrics |
In pandas, Index values must be?
A) unique | B) hashable |
C) Both A and B | D) None of the above |
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 |
A panel is a ___ container of data
A) 1D | B) 2D |
C) 3D | D) Infinite |
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 |
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 |
Which of the following makes use of pandas and returns data in a series or dataFrame?
A) pandaSDMX | B) freedapi |
C) OutPy | D) Inpy |
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 |
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 |
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 |
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 |
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 |
Which of the following input can be accepted by DataFrame?
A) Structured ndarray | B) Series |
C) DataFrame | D) All of the mentioned |
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 |
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 |
Series is a one-dimensional labeled array capable of holding any data type.
A) True | B) False |
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 |
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 |
If data is an ndarray, index must be the same length as data.
A) True | B) False |
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 |
DataFrame in pandas is
A) 1 dimensional array | B) 2 dimensional array |
C) 3 dimensional array | D) None of the above |
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 |
In data science, which of the python library are more popular ?
A) Numpy | B) Pandas |
C) OpenCv | D) Django |
Minimum number of argument we require to pass in pandas series ?
A) 0 | B) 1 |
C) A2 | D) 3 |
Series in Pandas is
A) 1 dimensional array | B) 2 dimensional array |
C) 3 dimensional array | D) None of the above |
Way to install the pandas library ?
A) install pandas | B) pandas install python |
C) python install pandas | D) None of the above |
we can analyze the data in pandas with :
A) Series | B) DataFrame |
C) Both of the above | D) None of the above |
What we pass in DataFrame in pandas ?
A)Integer | B) String |
C) Pandas series | D) All of the above |
In which of the following field, we can put our Button?
A) Window | B) Frame |
C) Label | D) All of the above |
SciPy stands for?
A) science library | B) source library |
C) significant library | D) scientific library |
Which of the following is not correct sub-packages of SciPy?
A) scipy.cluster | B) scipy.source |
C) scipy.interpolate | D) scipy.signal |
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 |
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. ]) |
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 |
what is constant defined for Boltzmann constant in SciPy?
A) G | B) e |
C) R | D) k |
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.]) |
In SciPy, determinant is computed using?
A) determinant() | B) SciPy.determinant() |
C) det() | D) SciPy.det() |
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 |
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 |
Flask is a web development framework created in ___________ language.
A) C | B) Java |
C) Python | D) Javascript |
Is the Flask framework open source?
A) TRUE | B) FALSE |
C) Can be true or false | D) Can not say |
It is released under the ___________ Clause.
A) BSD-0 | B) BSD-1 |
C) BSD-2 | D) BSD-3 |
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 |
WSGI stands for the?
A) Write Server Gateway Interface | B) Web Static Gateway Interface |
C) Web Server Gateway Interface | D) Web Server Gateway Interact |
Flask default port is?
A) 2000 | B) 3000 |
C) 4000 | D) 5000 |
Flask default host is a localhost (127.0.0.1)
A) TRUE | B) FALSE |
C) Can be true or false | D) Can not say |
Flask is called a?
A) miniframework | B) microframework |
C) peraframework | D) nanoframework |
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 |
Flask works with most of the RDBMSs, such as?
A) PostgreSQL | B) SQLite |
C) MySQL | D) All of the above |
How many except statements can a try-except block have?
A) zero | B) one |
C) more than one | D) more than zero |
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 |
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 |
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 |
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 |
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 |
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 |
What will be the output of the following Python code?
def foo(): try: print(1) +br> finally: print(2) foo()
A) 1 2 | B) 1 |
C) 2 | D) none of the mentioned |
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 |
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 |
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 |
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 |
Program code making use of a given module is called a ______ of the module.
A) Client | B) Docstring |
C) Interface | D) Modularity |
______ is a string literal denoted by triple quotes for providing the specifications of certain program elements.
A) Interface | B) Modularity |
C) Client | D) Docstring |
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 |
In top-down design every module is broken into same number of submodules.
A) True | B) False |
All modular designs are because of a top-down design process.
A) True | B) False |
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 |
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 |
Which of the following is not a valid namespace?
A) Global namespace | B) Public namespace |
C) Built-in namespace | D) Local namespace |
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 |
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 |
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 |
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)) |
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 |
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 |
Which block lets you test a block of code for errors?
A) try | B) except |
C) finally | D) None of the above |
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 |
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 |
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 |
Which exception raised when a calculation exceeds maximum limit for a numeric type?
A) StandardError | B) ArithmeticError |
C) OverflowError | D) FloatingPointError |
Which exception raised in case of failure of attribute reference or assignment?
A) AttributeError | B) EOFError |
C) ImportError | D) AssertionError |
How many except statements can a try-except block have?
A) 0 | B) 1 |
C) more than one | D) more than zero |
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 |
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 |
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 |
what is math.floor(0o10) ??
A) 8 | B) 10 |
A) 0 | B) 9 |
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) |
what is the value of x if x = math.sqrt(4)
A) 2 | B) 2.0 |
C) (2,-2) | D) (2.0,2.0) |
what will be the output of print(math.factorial(4,5))??
A) 24 | B) 120 |
C) error | D) 24.0 |
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 |
what is the output of print(math.pow(3,2))??
A) 9 | B) 9.0 |
C) None | D) none of the mentioned |
what is math.factorial(4,0)??
A) 24 | B) 1 |
C) error | D) none of the mentioned |
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 |
what is returned by int(math.pow(3,2))??
A) 6 | B) 9 |
C) error,third argument requires | D) error, too many arguments |
Not a member yet? Register now
Are you a member? Login now