NEW
Font size
WorksheetsSeason 1 #Spaic Python Weekly Quiz
Total questions: 20
Worksheet time: 10mins
Why are local variable names beginning with an underscore discouraged?
They are used to indicate a private variables of a class
They confuse the interpreter
They are used to indicate global variables
They slow down execution
What will be the output of the following Python code?
[‘ab’, ‘cd’]
[‘AB’, ‘CD’]
[None, None]
None of the mentioned
What will be the output of the following Python code?
True
False
None
None of the mentioned
Point out the correct statement.
If data is a list, if index is passed the values in data corresponding to the labels in the index will be pulled out
NaN is the standard missing data marker used in pandas
Series acts very similarly to a array
None of the mentioned
Given a function that does not return any value, What value is thrown by default when executed in shell.
Int
Bool
Void
None
What error occurs when you execute the following Python code snippet? apple = mango
SyntaxError
NameError
ValueError
TypeError
Which of the following operators has its associativity from right to left?
+
//
%
**
a.append(b)
a.extend(b)
Any of the above
None of these
tup=(1,2,3,4,5) You want to update the value of the tuple at the 2nd index to 10 Which is the correct way to do this?
tup(2) = 10
Tup[2] = 10
Tup{2} = 10
None of these
CityA=[“1”,”2”,”3”,”4”] CityB=[“2”,”3”’,”4”,”5”] Using this two lists ,Which of the following will find the names of cities in City_A but not in City_B
[i for i in City_A if i not in City_B]
[i for i in City_B if i not in City_A]
[i for i in City_A if i in City_B]
None of the above
In Python, lists and Dictionaries can store multiple data types
True
False
If you want to check membership of an element in a collection, which data type will allow you to do this faster
List
Set
What is the result of print (list[2:]) if list = [1,4,5,2,3]
[2,3]
[1,4,5,2]
[5,2,3]
[4,2]
Which are more compact and implemented more efficiently
Python lists
NumPy arrays
What does the ‘’.join() operation allow you to do
Convert a string to a list
Convert a list of strings to a string
Which of the following randomizes the items of a list in place?
shuffle(list)
capitalize(list)
rand(list)
isdigit(list)
What data type is the object below? L = [1, 23, 'apple', 1]
List
Dictionary
Array
Tuple
What arithmetic operators cannot be used with strings?
+
*
–
All of the mentioned
Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?
5
4
None
Error
Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?
[2, 33, 222, 14]
Error
25
[25, 14, 222, 33, 2]
