Font size
WorksheetsPython Quiz AX-7
Total questions: 81
Worksheet time: 59mins
The code snippet above outputs
error
None
NaN
-1
What is the output of the code above
None
Syntax Error
-1
Code doesn't compile
The output of the code above is
Key Error
4
Math
The code above prints
Math
Physics
Chemistry
English
4
3.8
3.6
3.7
None
None
None
None
NaN
NaN
NaN
NaN
What is the output of the program above
e
y
t
g
The output of the code above is
[101, 102, 103, 104]
[3.6, 3.7, 3.8, 4]
What is the output of the code above
[3.6, 3.7, 3.8, 4]
[101, 102, 103, 104]
Assume the key is the student's id and the value is the grade. Which of the following code will get the grade of student id 102.
grades[102]
grades.get(102)
grades[2]
grades[3]
grades.key(102)
Which of the following are valid ways to create a dictionary like this
Which of the following code deletes the key 103 and its value
del grades[103]
grades.pop(103)
del grades["103"]
grades.pop("103")
What is the output of the code above
3.9
4
Syntax error
What is the output of the program above
7
6
5
9
4
How to fix the syntax error above ?
grades.pop("Science", None)
grades.pop["Science","None"]
del grades["Math"]
del grades["Math", None]
What is the problem with the code above ?
Dictionary cannot be changed during an iteration
This code will run fine (without syntax errors)
After all the grades are popped, there are no elements remaining. The print statement will throw a syntax error.
Tuples in Python are mutable
False
True
How to create a single element tuple
(1,)
(1)
{1}
[1]
tuple([1])
Result of the program above is
('1', '2', '3', '4', '5')
(1, 2, 3, 4, 5)
12345
"12345"
What is the output of the program above
<class 'tuple'>
<class 'None'>
<class 'list'>
<class 'int'>
What is the output of the code above
(1, '2', 3, 4, 5)
syntax error
(1, 2, 3, 4, 5)
('1', '2', '3', '4', '5')
Which of the following is true
a is assigned a value of 1
b is assigned a value of [2,3]
b is assigned a value of (2,3)
b is assigned a value of 2
What is the output of the program above ?
b is bigger
a is bigger
Syntax error : tuples can't be compared
What is the output of the code above ?
1 4
1
1 None
1 [2,3,4]
1 (2,3,4)
What is the output of the program above ?
True
False
Find T ?
T=144 / 2 + 5 * 9 - ( 8 -3 )
106
688
112
684
Find the Output:
Item = {"ECE" , "CSE" , "EEE" , "CIVIL"}
Item.add (2,"MECH")
print(Item)
{ "ECE" , "MECH" , "CSE" , "EEE" , "CIVIL" }
{ "ECE" , "CSE" , "MECH" , "EEE" , "CIVIL" }
{ "ECE" , "CSE" , "EEE" , "CIVIL" }
{ "ECE" , "CSE" , "EEE" ,"MECH" , "CIVIL" }
Find the Output ?
A = "Anand Institute of higher technology"
print ( A[-5:7]
_Institute of higher techn
nstitute of higher technol
d Institute of higher techn
Institute of higher techno
def.number (r1 , r2)
sum = r1 / r2
return sum
a = number (r2 = 15 , r1 = 10)
2 / 3
3 / 2
error
2
what is the output of the following code ?
var1 = 1
var2 = 2
var3 = "3"
print (var + var2 var3)
Error. Mixing operators between numbers and strings are not supported
6
33
123
Which of the following function convert a string to a float in python ?
float(X)
int(x[,base])
long(X[,base])
str(X)
what is the output of the following programing ?
X = [ 'ab' , 'cd' ]
for i in X:
i.upper()
print (x)
[ 'AB' , 'CD' ]
[ 'ab' , 'cd' ]
[ AB , CD ]
ERROR
find p ?
p = ( 35 , 46 , 73 , 21 )
p.append( -2 , 24 )
print (p)
( 35 , 46 , 73 , 24 , 21 )
error
( 35 , 46 , 24 , 73 , 21 )
( 35 , 24 , 73 , 21 )
what will be the output of the following python code snippet ?
not (10 < 20) and not (10 > 30 )
TRUE
FALSE
Find the output ?
a = True
b = False
c = False
if a or b and c :
print "INFYTQ"
else:
print "infytq"
infytq
INFYTQ
ERROR
In a Python program, a control structure:
Defines program-specific data structures
Directs the order of execution of the statements in the program
Manages the input and output of control characters
Dictates what happens before the program starts and after it terminates
Syntax error in python is detected by _________at _______
interpreter/ run time
compiler/ compile time
compiler/ run time
interpreter/ compile time
Which one of the following if statements will not execute successfully:
if (1, 2):
print('foo')
if (1, 2):
print('foo')
if (1, 2):
print('foo')
if (1, 2): print('foo')
if (1, 2):
print('foo')
Which among them will produce {'a', 'b', 'c'}?
Tuple(''abc'')
Set(''abac'')
List(''abc'')
None of the above.
Which among them is incorrect for set s={100,101,102,103}
Max(s)
Sum(s)
Len(s)
Print(s[3])
What signifies the end of a statement block or suite in Python?
A comment
end
A line that is indented less than the previous line
}
What is the output for −
S = [['him', 'sell'], [90, 28, 43]]
S[0][1][1]
'e'
'i'
'90'
'h'
The following if/elif/else statement will raise a KeyError exception:
d = {'a': 0, 'b': 1, 'c': 0}
2
3if d['a'] > 0:
4 print('ok')
5elif d['b'] > 0:
6 print('ok')
7elif d['c'] > 0:
8 print('ok')
9elif d['d'] > 0:
10 print('ok')
11else:
12 print('not ok')
TRUE
FALSE
What is the output of the following
l = [None] * 10
print(len(l))
10
0
Syntax Error
Select all the correct options to copy a list
aList = ['a', 'b', 'c', 'd']
newList = copy(aList)
newList = aList.copy()
newList.copy(aList)
newList = list(aList)
The output of the code above will be
0
1
99
How to add these two numbers
age = int(age_1) + int(age_2)
age = int(age_1 + age_2)
age = age_1 + age_2
The string enclosed in triple quotes is called the doc string. It is used to
Show the documentation about the function
be read by the developer reading the function code
Which of the following code is true
square() will return 25
square(3) will return 9
Which of the following is true
The code above will result in syntax error
square(2,2) will result in a value of 4
square(2,3) will result in a value of 9
The above code is the signature of the print function in Python.
*objects represents
Variable number of arguments that can be passed as strings
pointer to objects in memory
The code above
Takes in variable number of arguments and returns the sum of them
Takes in a pointer to a list of numbers and returns the sum of them
The output of the code above is
<class 'tuple'>
<class 'list'>
<class 'dict'>
<class 'string'>
<class 'iterable'>
The output of the code above is
40
30
syntax error
What is the output of Following code?
List = ['spam', 2.0, 5, [10, 20]]
print(List[2])
(a)
What is the output of Following code?
cheeses = ['Cheddar', 'Edam', 'Gouda']
numbers = [42, 123]
print(cheeses, numbers)
['Cheddar', 'Edam', 'Gouda'] [42, 123]
[42, 123] ['Cheddar', 'Edam', 'Gouda']
Compilation Error
No output
What is output of the following Code (Execute in Intrepreter)
cheeses = ['Cheddar', 'Edam', 'Gouda']
'Edam' in cheeses
(a)
In Python, list is mutable
True
False
Which of the following commands will create a list?
list1 = list()
list1 = []
list1 = list([1, 2, 3])
list1 = new List()
What is the output of the following code?
list = [1,2,3,4,5,6,7,8,9,10]
print(list[1:2])
(a)
What is the output of the following code?
list = [1,2,3,4,5,6,7,8,9,10]
print(list[2:1])
(a)
What is the output of the following code?
list = [1,2,3,4,5,6,7,8,9,10]
print(list[::-1])
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
[1,2,3,4,5,6,7,8,9,10]
Error
No output
What is the output of the following code?
list = [1,2,3,4,5,6,7,8,9,10]
print(list[::-3])
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
Compilation error
[8,9,10]
[10, 7, 4, 1]
What is the output of the following code?
list = []
list.append(1)
list.append(2.0)
list.append("vk")
print(list)
[1, 2.0, 'vk']
Error
['vk', 1, 2.0]
No putput
What will be the output of the following Python code?
a) 1
2
3
b) error
c) 1
2
d) none of the mentioned
What are the values of the following Python expressions?
2**(3**2)
(2**3)**2
2**3**2
a) 512, 64, 512
b) 512, 512, 512
c) 64, 512, 64
d) 64, 64, 64
What will be the output of the following Python program?
a) error
b) 0 1 2 0
c) 0 1 2
d) none of the mentioned
What will be the output of the following Python code?
a) 1 2 3 4 5 6
b) 1 2 3 4 5 6 7
c) error
d) none of the mentioned
What will be the output of the following Python code?
a) 1
b) 1 3 5 7.....
c) 1 2 3 4..... .
d) none of the mentioned
What will be the output of the following Python code?
a) a b c d
b) 0 1 2 3
c) error
d) none of the mentioned
What will be the output of the following Python code?
a) a b c d
b) 0 1 2 3
c) error
d) 1 2 3 4
What will be the output of the following Python code?
a) 0 1 2
b) a b c
c) {0: 'a', 1: 'b', 2: 'c'}
{0: 'a', 1: 'b', 2: 'c'}
{0: 'a', 1: 'b', 2: 'c'}
d) none of the mentioned
What will be the output of the following Python code?
for i in range(0):
print(i)
a) 0
b) no output
c) error
d) none of the mentioned
What will be the output of the following Python code snippet?
a) 0 1 2 3 4 …
b) 0 -2
c) 0
d) error
What will be the output of the following Python code?
a) 0 1 2 3 4 Here
b) 0 1 2 3 4 5 Here
c) 0 1 2 3 4
d) 1 2 3 4 5
1. True of False: When increased readability or elimination of complexity are important, then normal predefined python functions may be of more value than corresponding Lambda ones.
a. True
b. False
2. Which of the following statements about
Python Lambda functions are true? Select all that apply:
a. Lambda functions are used with functional programming.
b. Lambda functions can be useful as quick, throwaway, single line functions.
c. Lambda Functions are useful as input to other functions
d. All of the above.
a. 10
b. 10.0
c. num
d. SyntaxError, return is invalid
4. What are the common functional programming functions
that use lambdas? Select all that apply:
a. filter()
b. map()
c. reduce()
d. lookup()
a. Syntax error, lambda functions cannot contain the named key parameter
b. No output, exception will be raised on middle line
6. What did you like most about this training session? All feedback welcome.
7. To receive a copy of the guide, please enter your personal internet email below.
Which of the following is the output of the below Python code?
var1 = lambda var: var * 2
ret = lambda var: var * 3
result = 2
result = var1(result)
result = ret(result)
result = var1(result)
print(result)
24
12
7
36
48
