WorksheetsTeam Quiz 1
Total questions: 50
Worksheet time: 1hrs 20mins
What will the following code segment print?
print(“Career”)
print(“Labs”)
CareerLabs
Career Labs
Career Labs(in next line)
"Career" "Labs"
What will be the output of the given code segment?
a = 10
b = 20
multiple = a*b
print("multiple")20
200
multiple
none
Select correct variable name(s) which are allowed in python language.
One or more options may be correct
var1
var_1
1var
_var1
Consider the python code below -
x = "abcd"
x = 10
What is the type of x after the code executes ?
str
int
What will be the output of following statement?
print(17//10)1.7
1
2
none
What will be the output of the code if the input provided is 40 and 57 ?
a = input()
b = input()
C = a+b
print(C)
Note that the double quotes given in the options is to denote that it is a string. It wouldn't appear in the final output.
90
"40+57"
"4057"
none
What will be the output of the code if input provided is 40 and 57 ?
a =int (input())
b= int (input())
C = a+b
print(C)90
"40+57"
"4057"
none
What is the type of the following number: 3.12323
float
int
What is the result of the following: int(3.99)
3
3.99
What is the value of x after the following is run:
x=4
x=x/2
2.0
4.0
What is the result of the following: Name[0]
"M"
"n"
"i"
What is returned by the following function?
4
5
false
3.14
What is returned by the following function?
56
c
cat
Error, you cannot have two index values unless you are using slicing.
What is returned by the following function?
[4, 2, 8, 999, 5, 4, 2, 8, 999, 5]
[[4, 2, 8, 999, 5], [4, 2, 8, 999, 5]]
[4, 2, 8, 6, 5]
[[4, 2, 8, 999, 5], [4, 2, 8, 6, 5]]
6
0
120
Error
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?
[3, 4, 5, 20, 5, 25, 1, 3]
[3, 5, 20, 5, 25, 1, 3]
[1, 3, 3, 4, 5, 5, 20, 25]
[1, 3, 4, 5, 20, 5, 25]
What is the output when we execute list(“hello”)?
[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
[‘hello’]
[‘llo’]
[‘olleh’]
Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation?
print(list1[2:])
print(list1[:2])
print(list1[:-2])
All
A
Daman
Error
n
Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)
0
1
4
2
2
4
5
8
The ________ function returns its argument with a modified shape, whereas the ________ method modifies the array itself.
reshape, resize
resize, reshape
reshape2, resize
all of the mentioned
What is NumPy library ?
library with a large collection of high-level mathematical functionsis a library written for the Python programming language for data analysis.
What is the default data type of NumPy arrays?
int32
float64
object
None of the above
What is the output of the following code?
[2, 3, 4]
[0, 1, 2]
[5, 6, 7]
[2, 4, 6]
What is the output of the following code?
[1, 2, 3, 4, 5, 6]
[[1, 4], [2, 5], [3, 6]]
[5, 7, 9]
Error
What is the output of the following code?
[[19, 22], [43, 50]]
[[5, 6], [7, 8], [1, 2], [3, 4]]
[[1, 5], [2, 6], [3, 7], [4, 8]]
Error
What is the output of the following code?
[[1, 2, 3], [4, 5, 6]]
[[1, 4], [2, 5], [3, 6]]
[1, 2, 3, 4, 5, 6]
Error
Tuple: What will be the output of following code?
a = 5,6,7
print(a[1:])[6,7]
(6,7)
[5,6,7]
(5,6,7)
What will be the output of follwoing code?
a = 1,2
b = (4,5)
d = a+b
print(d[2])2
(4,5)
4
Error
What will be the output of following code?
d = {1:2, “abc”:5, “def”:7}
print(d[0])1:2
1
2
Error
Present
Not Present
Error
None
What will be the output of following code?
a = {1:2,’list’:[1,2],3:5}
a.pop(‘list’)
a[‘list’] = [3,5]
print(a[‘list’])None
[3,5]
[1,2]
Error
What will be the output of following code?
s = {}
s.add(4)
s.add(4)
print(len(s))2
1
Error
none
Which one of the following is correct?
In python, a dictionary can have two same keys with different values.
In python, a dictionary can have two same values with different keys
In python, a dictionary can have two same keys or same values but cannot have two same key-value pair
In python, a dictionary can neither have two same keys nor two same values.
What will be the output of the following Python code?
7
4
8
Error
Which of the following are true of Python dictionaries:
Dictionaries can be nested to any depth.
Dictionaries are accessed by key.
All the keys in a dictionary must be of the same type.
Dictionaries are mutable.
A dictionary can contain any object type except another dictionary.
Which of the following is not a valid way to define this dictionary in Python:
d = dict([
('foo', 100),
('bar', 200),
('baz', 300)
])
d = {}
d['foo'] = 100
d['bar'] = 200
d['baz'] = 300
d = dict(foo=100, bar=200, baz=300)
d = {'foo': 100, 'bar': 200, 'baz': 300}
d = { ('foo', 100), ('bar', 200), ('baz', 300) }
Consider this dictionary:
d = {'foo': 100, 'bar': 200, 'baz': 300}
What is the result of this statement:
d['bar':'baz']
It raises an exception
(200, 300)
200 300
[200, 300]
Which of these is the best description of a list in Python?
A list is a collection of data that has an order and can be changed
A list is a lot of variables
A list is used for shopping
A list is a collection of data that cannot hold duplicated data and cannot be changed
Which of these is the correct code for creating a list of names?
nameList = John, Harry, Jesse, John, Harry, Harry
nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList = [John, Harry, Jesse, John, Harry, Harry]
What is used to separate elements in a list?
Bracket
Comma
Full Stop
Space
Which code would i use to add an item to a list?
variable.add()
variable.append()
append.variable()
add.variable()
Identify the below expressions which would result in False?
a) False and True b) 1==1 or 2==1
c) 1==1 and 2!=1 d) True and 1==1 e) False or 1>2
c, d
a, e
b, c, d
a, c
What is a correct syntax to return the first character in a string?
x="Hello".sub(0,1)
x="Hello"[0]
x=sub("Hello",0,1)
x=substring("Hello",0,1)
what is the output of the below code snippet?
num1=10
num2=7//2
num2*=num1
print(num2)
10
35.0
30
30.0
What is the output of the below code snippet?
P 9
Q 10
R 2
S 6
Tuple is immutable, so it will throw an error
P 9
Q 10
R 2
S 6
T 6
None of the above
x = ['ab', 'cd']
for i in x:
i.upper()
print(x)
['ab','cd']
['AB','CD']
The result of this program:
Friday = False
if Friday:
print "Jeans day!"
else:
print "Uniform day"
Jeans day
Today is Friday
Uniform day
Not Friday
What is the output?
more than 7
more than 23
spam
7
