WorksheetsQuiz 2
Total questions: 25
Worksheet time: 13mins
What will be the output of the following Python program?
8
2
1
5
What will be the output of the following Python code snippet?
z=set('abc$def')
'a' in z
Error
No output
True
False
What will be the output of the following Python code?
print("Hello {0[0]} and {0[1]}".format(('foo', 'bin')))Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
Hello foo and bin
Error
None of the mentioned
Which function is used to read all the characters?
Read()
Readcharacters()
Readall()
readchar()
Which of the following are the modes of both writing and reading in binary format in file?
wb
w
wb+
w+
what does ~~~~~~~5 evaluate to ?
+11
-5
+5
-11
what will be the output of the following code?
x=1234
reg="integers:....%d...%-6d...%06d"%(x,x,x)
print(reg)
error
integers:....1234...1234 ...123400integers:....1234...1234 ...001234integers:....1234...1234...1234What will be the output of the following code?
good
false
bad
hello
what will be the output of the following code?
-2 -1
error
0
none of the above mentioned
what is the output of the following code?
A=[[1,2,3],
[4,5,6],
[7,8,9]]
A[1]
[1,2,3]
error
[2,5,8]
[4,5,6]
write a list comprehension for number and its cube for:
l=[1,2,3,4,5,6,7,8,9]
[x**3 in l]
[x^3 in l]
[x**3 for x in l]
[x^3 for x in l]
What is the output of the following code?
5 12
12 5
error
20, 5
int(1011)?
13
1011
11
1101
which function is used to find factorial of a number using math module?
fact()
factorial()
math.fact()
none of the above
What will be the output of the following Python code?
x = ['ab', 'cd']
print(len(list(map(list, x))))))2
4
error
none of the above
Which of the following concepts is not a part of Python?
Pointers
Loops
Dynamic Typing
All the above
What will be the output of the following code snippet?
Global
Local
None
Cannot be predicted
What will be the output of the following code snippet?
example = ["Sunday", "Monday", "Tuesday", "Wednesday"];
print(example[-3:-1])
['Monday', 'Tuesday']
['Sunday', 'Monday']
['Tuesday', 'Wednesday']
['Wednesday', 'Monday']
What will be the type of the variable sorted_numbers in the below code snippet?
numbers = (4, 7, 19, 2, 89, 45, 72, 22)
sorted_numbers = sorted(numbers)
print(sorted_numbers)List
Bubble sort
Tuple
String
What will be the output of the following code snippet?
dict1 = {'first' : 'sunday', 'second' : 'monday'}
dict2 = {1: 3, 2: 4}
dict1.update(dict2)
print(dict1)
{'first': 'sunday', 'second':'monday', 1: 3, 2: 4}
{1:3, 2:4}
{'first': 'sunday', 'second': 'monday'}
all the above
What will be the output of the following code snippet?
[0,1,4,9,16]
[1,4,9,16,25]
[0,1,2,3,4]
[1,2,3,4,5]
As what datatype are the *args stored, when passed into a function?
List
Tuple
Dictionary
None of the above
What will be the output of the following code snippet?
set1 = {1, 3, 5}
set2 = {2, 4, 6}
print(len(set1 + set2))
3
6
0
error
In which language is Python written?
c++
c
java
None of the above
What will be the output of the following code snippet?
from math import *
a = 2.19 b = 3.999999 c = -3.30
print(int(a), floor(b), ceil(c), fabs(c))
2 3 -3 3.3
3 4 -3 3
2 3 -3 3
2 3 -3.3 3
