123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 You Have 2 hours To Complete The Test / Quiz Programming and Problem Solving through Python (M3-R5.1) Total available questions is More than 1000. Each exam has 100 questions & Answers randomly. You will get 2 hrs to complete the test. Its Mandatory To Fill For Get Certificate After Complete Exam. NameEmail 1) What will be the output of the following Python code? >>> a={4,5,6} >>> b={2,8,6} >>> a-b a. Error as unsupported operand type for set data type b. {6} c. {4,5} d. Error as the duplicate item 6 is present in both sets 2) Which of the following is the same as list(map(lambda x: x**-1, [1, 2, 3]))? a. [1/x for x in [(1, 2, 3)]] b. error c. [x**-1 for x in [(1, 2, 3)]] d. [1/x for x in (1, 2, 3)] 3) The brain of computer system is a. ROM b. Control Unit c. RAM d. CPU 4) In which datatype we can store True/False type values a. Float b. String c. Boolean d. Integer 5) What is the output when we execute list(“hello”)? a. [‘llo’] b. [‘hello’] c. [‘h’, ‘e’, ‘l’, ‘l’, ‘o’] d. [‘olleh’] 6) Data Items having fixed value are called ______ a. Functions b. keywords c. Identifiers d. Literals 7) Which of the following is a valid arithmetic operator in Python ? a. // b. ? c. and d. < 8) What is called when a function is defined inside a class? a. Class b. Another function c. Method d. Module 9) Which of these in not a core data type? a. Tuples b. Class c. Dictionary d. Lists 10) What will be the output of the following Python code? print("abcdef".center(7, 1)) a. 1abcdef b. abcdef c. abcdef1 d. error 11) What type of data is: a=[(1,1),(2,4),(3,9)]? a. List of tuples b. Array of tuples c. Tuples of lists d. Invalid type 12) Which inbuilt function is used to takes an iterable object as input and makes them immutable. a. frozenset() b. obj() c. input() d. None of these 13) The write method returns ________. a. Algorithm b. None c. Variables d. connector 14) Which of the following is an invalid statement in python. a. a,b,c=200,300,400 b. abc=200 300 400 c. abc=2,00,000 d. a_b_c= 2,00,000 15) Select the reserved keyword in python. a. raise b. import c. else d. All of the mentioned 16) What will be the output of the following Python code? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [A[i][i] for i in range(len(A))] a. [3, 5, 7] b. [2, 5, 8] c. [4, 5, 6] d. [1, 5, 9] 17) The Compexity of linear search algorithm is a. O (n log n) b. O(n) c. O (log n) d. O(n2) 18) The function that yields current position in the file a. write() b. tell() c. Writelines() d. None of the above 19) If we not see the rules of th programming language, we get ? a. None of the above b. Runtime Error c. Syntax Error d. Logical Error 20) Python myfile.py is used to ____ file in command shell. a. Run b. compile c. Interpret d. None of the above 21) A detailed flow chart is called as______? a. micro b. stack c. macro d. union 22) What will be the output of the following Python code? l=["good", "oh!", "excellent!", "#450"] [n for n in l if n.isalpha() or n.isdigit()] a. [‘good’] b. [‘good’, ‘oh’, ‘excellent’, ‘450’ ] c. [‘good’, ‘#450’] d. [‘oh!’, ‘excellent!’, ‘#450’] 23) What will be the output of the following Python code? lst=[3,4,6,1,2] lst[1:2]=[7,8] print(lst) a. [3,[7,8],6,1,2] b. [3, 7, 8, 6, 1, 2] c. [3,4,6,7,8] d. Syntax error 24) What will be the output of the following Python code? x = (i for i in range(3)) for i in x: print(i) for i in x: print(i) a. 0 1 2 b. error c. 0 1 2 0 1 2 d. none of the mentioned 25) Which of the following is not a keyword in Python a. eval b. assert c. pass d. nonlocal 26) What is use of seek() method in files? a. sets the file's current position within the file. b. sets the file's previous position at the offset. c. sets the file's current position at the offset. d. None of the above 27) What will be the output of the following Python statement?(python 3.xx) >>>print(format("Welcome", "10s"), end = '#') >>>print(format(111, "4d"), end = '#') >>>print(format(924.656, "3.2f")) a. Welcome# 111#924.66 b. Welcome#111#.66 c. Welcome#111#924.66 d. Welcome # 111#924.66 28) _____ help programmers to create lists in a concise way. a. List Comprehensions b. Dictionary c. Tuple d. None of these 29) Which method is used to Write(s) a list of lines to the file. a. writelines (lines) b. write(s) c. readlines (lines) d. None of these 30) How many numbers will be printed by the following code? def fun(a,b): for x in range(a,b+1): if x%3==0: print(x,end=" ") fun(100,120) a. 8 b. 7 c. 6 d. 9 31) What will be the output of the following Python code snippet? x = 'abcd' for i in range(len(x)): x = 'a' print(x) a. a b. abcd abcd abcd c. none of the mentioned d. a a a a 32) An empty / null statement in Python is _____ . a. null b. None c. pass d. empty 33) Which symbol is used to write single line comment ? a. . b. ? c. / d. # 34) Part of an algorithm which is repeated for fixed number of times is classified as a. selection b. iteration c. reverse action d. sequence 35) The _____ function converts the specified value into a string. a. str() b. None of these c. String() d. int() 36) What is the current syntax of remove() a file ? a. remove(file_name) b. remove((), file_name) c. all of these d. remove(new_file_name, current_file_name,) 37) What will be the output of the following Python code? print('*', "abcdef".center(7), '*', sep='') a. * abcdef * b. * abcdef* c. * abcdef * d. *abcdef * 38) Can we write if / else into one line in python? a. No b. Yes c. None of the above. d. if / else not used in python 39) Write a list comprehension for number and its cube for l=[1, 2, 3, 4, 5, 6, 7, 8, 9]. a. [x^3 in l] b. [x**3 for x in l] c. [x**3 in l] d. [x^3 for x in l] 40) If a={5,6,7}, what happens when a.add(5) is executed? a. a={5,6,7} b. a={5,5,6,7} c. Error as there is no add function for set data type d. Error as 5 already exists in the set 41) What will be the output of the following Python code? def m(list): v = list[0] for e in list: if v < e: v = e return v values = [[3, 4, 5, 1], [33, 6, 1, 2]] for row in values: print(m(row), end = " ") a. 5 33 b. 5 6 c. 3 33 d. 1 1 42) When an algorithm is written in the form of a programming language it becomes a a. Syntax b. Program c. Flowchart d. Pseudo Code 43) What will be the output of the following Python code? >>>t1 = (1, 2, 4, 3) >>>t2 = (1, 2, 3, 4) >>>t1 < t2 a. False b. True c. Error d. None 44) The process of finding errors in code is called as a. Testing b. Debugging c. Compiling d. Running 45) What will be the output of the following Python code snippet? x = 2 for i in range(x): x += 1 print (x) a. 0 b. 0 -2 c. 0 1 2 3 4 … d. error 46) Is the following Python code valid? >>> a=2,3,4,5 >>> a a. Yes, 2 is printed b. No, too many values to unpack c. Yes, [2,3,4,5] is printed d. Yes, (2,3,4,5) is printed 47) What will be the output of the following Python code? d = {0: 'a', 1: 'b', 2: 'c'} for i in d: print(i) a. a b c b. 0 1 2 c. none of the mentioned d. 0 a 1 b 2 c 48) Shape() function in Numpy array is used to a. Display elements b. None of these c. change the shape of array d. Find the shape of the array 49) What will be the output of the following Python code? x = (i for i in range(3)) for i in x: print(i) a. 0 1 2 b. none of the mentioned c. 0 1 2 0 1 2 d. error 50) Which of the following expression is correct. a. 21%4=1 b. All of the mentioned c. 10-(5**5)=-5 d. -7*(10/2)=-35 51) What will be the output of the following Python code? >>> a=("Check")*3 >>> a a. Syntax error b. (‘CheckCheckCheck’) c. (‘Check’,’Check’,’Check’) d. * Operator not valid for tuples 52) Which of the following is correct to Identify the right way to close a file. a. File.close b. None c. File.close() d. Close(file) 53) ____ operator repeats a list for the given number of items. a. None of these b. * c. & d. + 54) Which of the following mode will refer to binary data ? a. r b. + c. b d. w 55) Which of the following is not a Keyword in Python ? a. operators b. continue c. break d. break 56) What will be the output of the following Python code def func(a, b=5, c=10): printa is, a, 'and b is', b, 'and c is',) func(13, 17) func(a=2, c=4) func(5,7,9) (A) a is 13 and b is 15 and c is 10 a is 2 and b is 5 and c is 4 a is 5 and b is 7 and c is 9 (B) a is 13 and b is 17 and cis 10 a is 2 and b is 4 and c is 4 a is 5 and b is 9 and c is 7 (C) a is 13 and b is 17 and c is 10 a is 2 and b is 5 and cis 4 a is 5 and b is 7 and c is 9 (D) None of the above a. option B b. option D c. option C d. option A 57) Flowchart and algorithms are used for a. easy testing and debugging b. Better programming c. Efficient Coding d. All 58) What is the value of the expression 100 / 25 ? a. 4.0 b. none of these c. 2.5 d. 4 59) What will be the output of the following Python code? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [[col + 10 for col in row] for row in A] a. [11, 12, 13], [14, 15, 16], [17, 18, 19] b. [[11, 12, 13], [14, 15, 16], [17, 18, 19]] c. Error d. [11, 12, 13, 14, 15, 16, 17, 18, 19] 60) Which function is used to Evaluates string and returns an object. a. eval(str) b. None of the above c. exp(x) d. str(x) 61) What will be the output of the following Python code snippet? print('1.1'.isnumeric()) a. None b. Error c. True d. False 62) Operations to be repeated a certain number of times are done by a. Sequential b. Loop c. Simple d. Selection 63) What is the value of the expression 10 + 3 ** 3 * 2? a. 64 b. 829 c. 739 d. 28 64) What will be the output of the following Python code snippet? print([if i%2==0: i; else: i+1; for i in range(4)]) a. [1, 1, 3, 3] b. [0, 2, 2, 4] c. error d. none of the mentioned 65) What will be the output of the following Python code? True = False while True: print(True) break a. False b. none of the mentioned c. None d. True 66) In python language, which of the following operators is the correct option for raising k to the power 1? a. k^ ^1 b. k**1 c. k^*1 d. k^1 67) In Python, ________ is not supported. a. None b. return values c. Tuple assignment d. Tuple comprehension 68) Which of the following is an invalid variable? a. foo b. _myvar c. my_string_1 d. 1st_string 69) What will be the output of the following Python code? >>> a={5,6,7,8} >>> b={7,8,10,11} >>> a^b a. {7,8} b. Error as unsupported operand type of set data type c. {5,6,7,8,10,11} d. {5,6,10,11} 70) To shuffle the list(say list1) what function do we use? a. list1.shuffle() b. random.shuffleList(list1) c. shuffle(list1) d. random.shuffle(list1) 71) What will be the output of the following Python code snipped if x = 1? x<<2 a. None of these b. 8 c. 2 d. 4 72) _____method calls the built-in Python help system. a. help.python() b. python.help () c. None of the Above d. help() 73) The error that can be pointed out by the compiler are a. Syntax errors b. Semantic errors c. None of the above d. logical errors 74) Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.reverse()? a. [25, 20, 5, 5, 4, 3, 3, 1] b. [3, 4, 5, 20, 5, 25, 1, 3] c. [3, 1, 25, 5, 20, 5, 4, 3] d. [1, 3, 3, 4, 5, 5, 20, 25] 75) What will be the output of the following Python code snippet? print('0xa'.isdigit()) a. None b. True c. False d. Error 76) The Python prompt indicates that Interpreter is ready to accept instruction. a. # b. << c. >>> d. <<< 77) What will be the result of the expression 5 or 10 ? a. 0 b. 10 c. 1 d. 5 78) NumPY stands for. - a. Numbering Python b. Numerical Python c. None of the above d. Number In Python 79) What will be the output of the following Python code? >>> a=(1,2,(4,5)) >>> b=(1,2,(3,4)) >>> a<b a. Error, < operator is valid for tuples but not if there are sub-tuples b. False c. Error, < operator is not valid for tuples d. True 80) What will be the output of the following Python code snippet? print([i+j for i in "abc" for j in "def"]) a. [‘ad’, ‘ae’, ‘af’, ‘bd’, ‘be’, ‘bf’, ‘cd’, ‘ce’, ‘cf’] b. [[‘da’, ‘db’, ‘dc’], [‘ea’, ‘eb’, ‘ec’], [‘fa’, ‘fb’, ‘fc’]] c. [[‘ad’, ‘bd’, ‘cd’], [‘ae’, ‘be’, ‘ce’], [‘af’, ‘bf’, ‘cf’]] d. [‘da’, ‘ea’, ‘fa’, ‘db’, ‘eb’, ‘fb’, ‘dc’, ‘ec’, ‘fc’] 81) What will be the output of the following Python code? string = "my name is x" for i in string.split(): print (i, end=", ") a. m, y, , n, a, m, e, , i, s, , x, b. my, name, is, x, c. m, y, , n, a, m, e, , i, s, , x d. error 82) Is the following Python code valid? >>> a=(1,2,3) >>> b=('A','B','C') >>> c=zip(a,b) a. Yes, c will be ((1,2,3),(‘A’,’B’,’C’)) b. No because tuples are immutable c. Yes, c will be ((1,2,3),(‘A’,’B’,’C’)) d. No because the syntax for zip function isn’t valid 83) To insert 5 to the third position in list1, we use which command? a. list1.insert(3, 5) b. list1.add(3, 5) c. list1.insert(2, 5) d. list1.append(3, 5) 84) filter() is used to a. B. filters the given sequence with the help of a function that tests each element in the sequence to be true or not. b. Both of the above c. constructs an iterator from elements of an iterable for which a function returns true. d. None of the above 85) What will be the output of the following Python code? >>> a=[(2,4),(1,2),(3,9)] >>> a.sort() >>> a a. [(2,4),(1,2),(3,9)] b. Error, tuple has no sort attribute c. Error because tuples are immutable d. [(1, 2), (2, 4), (3, 9)] 86) What signifies the end of a statement block or suite in Python ? a. A comment b. end c. A line that is indented less than the previous line d. } 87) ___ in Python is a counter-controlled loop. a. None of the above b. while c. Both A and B d. for 88) Which amongst this is not a jump statement ? a. continue b. for c. break d. goto 89) _____function takes a list of lines to be written to file. a. writelines() b. tell() c. write() d. None of these 90) ____ help to check the data type of an array- a. None of these b. dtype.arr() c. arr.dtype() d. arraydtype() 91) Row data assigned to a variable is called as. a. literal b. variable c. comment d. identifier 92) What will be the output of the following Python code? >>> a=(0,1,2,3,4) >>> b=slice(0,2) >>> a[b] a. Invalid syntax for slicing b. (0,2) c. (0,1) d. [0,2] 93) Which of the following is correct about Python a. It can be easily integrated with C,C++,COM, ActiveX, CORBA, and java b. None of the above c. Both of the above d. It supports automatic garbage collection 94) What will be the output of the following Python code? i = 1 while False: if i%2 == 0: break print(i) i += 2 a. none of the mentioned b. 1 c. 1 3 5 7 … d. 1 2 3 4 … 95) What will be the output of the following Python code? print("abcdef".center(10, '12')) a. 1212abcdef b. error c. abcdef1212 d. 12abcdef12 96) What will be the output of the following Python expression if x=22.19? print("%5.2f"%x) a. 22.19 b. 22.00000 c. 22.20 d. 22.1900 97) The correct extension of the Python file is a. pyth b. python c. py d. none of these 98) Kite/diamond symbol in flow chart is used for_______ a. Execution b. All of the above c. Statement d. Decision 99) What will be the output of the following Python code? x = "abcdef" i = "a" while i in x: x = x[1:] print(i, end = " ") a. a a a a a a b. a c. no output d. error 100) The GCD of the numbers 136 and 170 is ______ . a. 50 b. None c. 34 d. 40 Your score is