Python - IT & Programming
Practice questions to test your knowledge and improve your understanding.
What will be the output of following code? d = lambda p: p * 2 t = lambda p: p * 3 x = 2 x = d(x) x = t(x) x = d(x) print x
What is the purpose of the map function?
Which of the following code samples will read arguments if the script is run from the command line?
Invoking the ___ method converts raw byte data to a string?
What is one of the most common use of Python's sys library?
Which of the following will throw an exception in Python?
Find the output of the following Python code and choose the correct answer from the given options.double = lambda x: x * 2mt = [1, 5, 4, 6, 8, 11, 3, 12]ns = list(filter(lambda x: (x%2 == 0) , mt))print(double(6))print(ns)
How can an element be removed from a list using its list index?
What is the basic difference between theses two operations in 're' module: match() and search()?
Which of the following options does not contain duplicate elements?
Read the following statements:>>> import string>>> str = "Mary had a lamp in her Hand">>> str = string.replace(str, 'ha', 'stan')>>> strWhich of the following will be the output?
What is the correct syntax for instantiating a new object of the type Game?
Analyse the given Python code and answer the question that follows.def att_d(fun):fun.data = 3return fun@att_ddef xyz (x. y):return x + y鈥�print(xyz(2, 23))print(xyz.data)What will be the correct output of the above Python code?
In Python 3.2's stand CPython implementation, all built-in types support weak-referencing.
What will typing the following at the Python interpreter produce? sequence = ['A','B','C','D','E','F'] ; sequence[1:2:3]
Read the following statements:>>> import string>>> s = 'mary\011had a little lamb'>>> print sWhich of the following will be the output of the above code snippet?
class Foo(object): def bar(self, x): pass foo = Foo() is foo.bar and foo.bar.__func__ is the same object?
Various email and news clients store messages in a variety of formats, many providing hierarchical and structured folders. Which of the following provides a uniform API for reading the messages stored in all the most popular folder formats?
Which of these will allow you to put more than one statement in one line of text?
Which Python implementation is best for testing Java code?
Which of the following databases can be used with Python?1. MySQL2. Oracle3. Maria DB4. Microsoft SQL Server
Consider the Python 3.4.2 code that is given in the image. Choose the correct line(s) number from thefollowing options that will not give an output as "None".
What will be the correct output of the following Python code?lst = [3, 1, 2, 5, 4, 3, 8]del lst[2 : 5]print (end="")for i in range(0, len(lst)):print(lst[i]+1, end=" ")print("\r")lst.pop(2)print (end="")for i in range(0, len(lst)):print(lst[i]+2, end=" ")
What will be the correct output of the following Python code?lis = [11, 22, 33]lis1 = [14, 5, 6]lis2= lis + lis1print (end="")for i in range(0,len(lis2)):print (lis2[i]*1, end=" ")print ("\r")lis3 = lis * 2print (end="")for i in range(0,len(lis3)):print (lis3[i]+1, end=" ")
What is the index of the first item in a tuple or list?
All Warnings in Python are subclassed from:
What is a future statement?
The side option of the pack manager may be _____?
What built-in list method would you use to remove items from a list?
Which of the following code snippets concatenates the list a_list = [1, 2, 3] with the tuple a_tuple = (4, 5), so the result would be [1, 2, 3, 4, 5]?
Python 2.3+ includes a standard module that implements a set datatype. Which of the following statements is true about the set datatype?
Choose the option below for which instance of the class cannot be created
What will be the output of this code? [1,2,3] * 3
Which of the following is true regarding urlopen function from the standard module urllib in Python 2?
Read the following code snippet: >>> o1 = C() >>> o1.lst = [1,2,3] >>> o3 = copy.deepcopy(o1) >>> o1.lst.append(17) What will be the output of '>>> o3.lst' and '>>> o1.lst'?
Which of the following is floor division ?
How can you define a tuple having one element?
What will be the output of the following? my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] new_list = list(filter(lambda x: (x%2 == 0) , my_list)) print(new_list)
Which of the following functions is used to send audio data via the Internet?
What will be the correct output of the following Python code?import matha = 3.4536print ("Result = ",end="")print (math.trunc(a)+math.ceil(a)+math.floor(a))
What is the method to retrieve the list of all active thread objects?
On a Unix-like system, what does Python's sleep.time() function block?
When opening a file, what is the difference between text mode and binary mode?
Which statement is true regarding the __all__ module level variable?
Which of the following is the base language of Python?
Which of the following code samples will determine the last day of a given month?
Which built-in Python function can be used to get the length of a list, tuple, string, dictionary or other object?
What will be the correct output of the following Python code?def abc():y = 2018if (y % 4) == 0:if (y % 100) == 0:if (y % 400) == 0:print("0")else:print("1")else:print("0")else:print("1")abc()
Which of these is NOT a characteristic of namedtuples?
What are the states/features supported by a RLock object?