Python: Variable, Keywords
Nom : Alatrache Hafsa
Groupe :3
*Obligatoire
How to swap two variables in one line ? *
1 point
x=y
x ^= y ^= x ^= y
x, y = y, x
(x ^= y), (y ^= x), (x ^= y)
Output of print(f"Python {3 + .2}") *
1 point
3.2
3+.2
Shows error
Python 3.2
Which of the following is an invalid statement? *
1 point
num = 1,000,000
xyz=123
x,y,z = 1, 2, 3
x_y_z = 1,000,000
What is the output of the following code? *
1 point
25
75
35
None
What is the maximum possible length of an identifier? *
1 point
31 characters
63 characters
79 characters
None of the above
Which of the following is not a keyword? *
1 point
open
lambda
is
except
What is the output of the following code? *
1 point
25
15
Error
None
From the execution of the statements n = 300, m = n how many objects and references will
be created? *
1 point
Two objects, two references
One object, two references
Two objects, one reference
One object, one reference
What is the output of the following code? *
1 point
50
100
Error
None
What is the output of the following code? *
1 point
JhonsJhonsJhonsJhons
Jhons
JhonsJhonsJhonsJhonsJhonsJhons
Syntax Error
Why are local variable names beginning with an underscore discouraged? *
1 point
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
Which of the following is not a keyword? *
1 point
pass
class
max
def
Which of the following is an invalid variable? *
1 point
odd_num_1
1_odd_num
num
What is the output of the following code? *
1 point
0
63
Error
None
Is Python case sensitive while dealing with identifiers? *
1 point
Yes
No
OS dependent
None of the above
Select the correct output of the following code. *
1 point
Python
15
Blank
In Python, a variable must be declared before it is assigned a value: *
1 point
True
False
Is Python case sensitive when dealing with identifiers? *
1 point
None of the above
Yes
No
machine dependent
All keywords in Python are in _________ *
1 point
Lower case
Upper case
None of the mentioned
Capitalized
Which of the following are valid Python variable names: *
1 point
ver1.3
return
home_address
route66
Age
4square
What is the output of the following code? *
1 point
25
15
Error
None
In Python if a variable is assigned a value anywhere within the function’s body, it’s
assumed to be a local unless explicitly declared as global. *
1 point
True
False
What is the maximum possible length of an identifier or an attribute ? *
1 point
32
64
79
Any length
Autre :
Which of the following are Python reserved words (keywords): *
1 point
default
and
goto
class
None
Which of the following statements assigns the value 100 to the variable x in Python: *
1 point
let x = 100
x := 100
x ← 100
x = 100
x << 100
Which of the following cannot be a variable ? *
1 point
_name_
def
at
on
Which of the following cannot be a variable? *
1 point
__init__
in
it
on
Which of the following is not a variable? *
1 point
on
__init__
in
it
What is the output of the following code? *
1 point
70
63
152530
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Which of the following is not a keyword? *
1 point
eval
assert
nonlocal
pass
Which of the following is true for variable names in Python? *
1 point
all private members must have leading and trailing underscores
underscore and ampersand are the only two special characters allowed
unlimited length
none of the mentioned
All keywords available in Python are in *
1 point
Uppercase
Lowercase
Both uppercase and lowercase
CamelCase
What is the output of the following code? *
1 point
0
70
Error
None
In Python, a variable may be assigned a value of one type, but later it can assigned a value
of a different type: *
1 point
True
False
Which of the following is an invalid variable? *
1 point
_var_
1var
_var_1
All the above
What Python built-in function returns the unique number assigned to an object: *
1 point
refnum()
id()
ref()
identity()
Which of the following is valid ? *
1 point
_var = 'python'
__var = 'python'
_name_ = 'python'
All the above
Which of the following is an invalid statement? *
1 point
a_b_c = 100
abc = 100, 'python'
a b c = 1 00
a, b, c = 1, 0, 0
What is the output of the following code? *
1 point
75
0
Error
Non
Part B :
What should the below code print? *
1 point
<class 'complex'>
<class 'unicode'>
<class 'int'>
<class 'float'>
<class 'dict'>
Which of the following is incorrect? *
1 point
a = 0b101
a = 0x4f5
a = 19023
a = 03964
Select all numeric data types in Python *
1 point
String
Integer
Double
Float
Complex number
Which of the following is incorrect? *
1 point
float('inf')
float('nan')
float('56'+'78')
float('12+34')
In order to execute an operation over arguments of different data types, convert all of them
to the same type beforehand. *
1 point
True
False
What does 3 ^ 8 evaluate to? *
1 point
81
24
11
5
Complex numbers in Python have real and imaginary parts. In Python they are represented
as: *
1 point
One Integer and one floating point number
Each is floating point number
Each is Integer
Both are strings
Select all immutable basic data types: *
1 point
Dictionary
String
Integer
Set
Float
List
Tuple
Which of the following data types can be used as keys in dictionaries in Python? Select all
that apply *
1 point
List
Set
Integer
String
Dictionary
Any type of value
List in Python can hold elements of same type only. True or False? *
1 point
True
False
What gets printed? *
1 point
<class 'int'>
<class 'list'>
<class 'tuple'>
<class 'dict'>
<class 'set'>
What will be the output of the following Python code snippet? *
1 point
indentation Error
cannot perform mathematical operation on strings
hello2
hello2hello2
What is the return type of function id? *
1 point
int
float
bool
dict
What gets printed *
1 point
<class 'set'>
<class 'dict'>
<class 'list'>
<class 'tuple'>
<class 'object'>
What error occurs when you execute the following Python code snippet? *
1 point
SyntaxError
NameError
ValueError
TypeError
Which of these in not a core data type? *
1 point
Lists
Dictionary
Tuples
Class
Which of the following results in a SyntaxError? *
1 point
‘”Once upon a time…”, she said.’
“He said, ‘Yes!'”
‘3\’
”’That’s okay”’
What is the output of the following code? *
1 point
<class 'tuple'>
<class 'int'>
<class 'set'>
<class 'complex'>
<class 'list'>
Strings in Python should be en-quoted in double quotation marks (“). True or False? *
1 point
True
False
What is the output of print 0.2 + 0.3 == 0.5? *
1 point
True
False
Error
In Python types are directly interpreted by the compiler, so check the following operation to
be performed. *
1 point
Objective is to make sure a has a integer value, select all that apply (Python 3.xx)
a = 15 // 3
a = int(15 / 3)
a = 15 % 3
All of the mentioned
In order to store values in terms of key and value which core data type is used. *
1 point
list
tuple
class
dictionary
What gets printed? *
1 point
abb
abb abb
abb 2
2
Error
What is the output of the following code? *
1 point
<class 'NoneType'>
<class 'tuple'>
<class 'type'>
<class 'function'>
<class 'bool'>
Which of the following is not a complex number? *
1 point
a = 2 + 3j
a = complex(2, 3)
a = 2 + 3l
a = 2 + 3J
What does ~5 evaluate to? *
1 point
-5
-7
-6
-5
Which of the following can be used as a dictionary key? *
1 point
list
set
dictionary
tuple
None of the above
What gets printed? *
1 point
<class 'int'>
<class 'number'>
<class 'float'>
<class 'double'>
<class 'tuple'>
What is the return value of trunc()? *
1 point
int
bool
float
None
What gets printed? *
1 point
<class 'function'>
<class 'tuple'>
<class 'NoneType'>
<class 'str'>
<class 'type'>
Boolean type is a subtype of Integer data type in Python *
1 point
True
False
Select all valid basic data types in Python 3 *
1 point
Double
String
Integer
Boolean
Float
Decimal
Union
Complex number
What data type is the object below? *
1 point
list
dictionary
array
tuple
If x and y are strings, which of the following is equivalent to [x] + [y] ? *
1 point
[x].extend([y])
[x,y]
[x + y]
[x].append(y)
Only immutable data types can be used as keys for dictionaries in Python. True or False? *
1 point
True
False
What is the type of inf? *
1 point
Boolean
Integer
Float
Complex
What is the result of round(0.5) - round(-0.5) *
1 point
1.0
2.0
0.0
None of the mentioned
Which of the following will run without errors? *
1 point
round(45.8)
round(6352.898,2,5)
round()
round(7463.123,2,1)
Given a function that does not return any value, What value is thrown by default when
executed in shell. *
1 point
int
bool
void
None
What does ~~~~~~6 evaluate to? *
1 point
6
-5
-11
11
Part C : String
*Obligatoire
What will be displayed by print(ord('b') - ord('a'));? *
1 point
1
0
-1
2
What will be the output of the following Python code snippet? *
1 point
Pq rs tu
Pq rs tU
Pq Rs Tu
None of the mentioned
What will be the output of the following Python code? *
1 point
True
False
None
Error
What will be the output of the following Python code? *
1 point
Python fff and bbb
Python (‘fff’, ‘bbb’) and (‘fff’, ‘bbb’)
Error
None of the mentioned
Suppose s is “\t\tWorld\n”, what is s.strip()? *
1 point
\t\tworld\n
\t\tWorld\n
\t\tWORLD\n
World
What will be the output of the following Python code? *
1 point
4
0
Error
True
What will be the output of the following Python code? *
1 point
x
2xy@
xy
y
What will be the output of the following Python statement? *
1 point
p
pq
rs
sr
What will be the output of the following Python code? *
1 point
Python {} and {}
Python fbb and bin
Error
Python and
What will be the output of the following Python code? *
1 point
snow
beautiful world
Error
beabtiful world
What will be the output of the following Python code snippet? *
1 point
abbabbababaab
10b10b1010a10
12babbababaab
babbababaab12
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What will be the output of the following Python code? *
1 point
Jack Roy
Robin Roy
Jack Smith
Robin Smith
What will be the output of the following Python code? *
1 point
True
False
None
error
What will be the output of the following Python code snippet? *
1 point
2,223,334,445
222,333,444,5
2223334445
Error
What will be the output of the following Python statement? *
1 point
x
yz
yzx
xyz
To concatenate two strings to a third what statements are applicable? *
1 point
s3 = s1 . s2
s3 = s1.add(s2)
s3 = s1.__add__(s2)
s3 = s1 * s2
What will be the output of the following Python code snippet? *
1 point
3,334,445,556
333,444,555,6
3334445556
Error
What will be the output of the following Python code? *
1 point
xyz. PQR
XYZ. PQR
Xyz. pqr
Xyz. Pqr
What will be the output of the following Python code snippet? *
1 point
10b10b1010a10
abbabbababaab
none of the mentioned
error
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What will be the output of the following Python code? *
1 point
1pqrstv
pqrstv1
pqrstv
error
What will be the output of the following Python code snippet? *
1 point
mn22qr
mn22qr22
mnopqr22
none of the mentioned
What will be the output of the following Python code snippet? *
1 point
Error
The sum of 5 and 12 is 17
The sum of 0 and 1 is 2
None of the mentioned
What will be the output of the following Python code? *
1 point
a new line and world
\nworld
the letter r and then world
error
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What will be the output of the following Python code? *
1 point
True False
True True
False True
False False
What will be the output of the following Python code? *
1 point
terwarldwo
True
-1
None
What will be the output of the following Python code? *
1 point
2
0
1
error
What will be the output of the following Python code? *
1 point
2
0
1
none of the mentioned
What will be the output of the following Python code snippet? *
1 point
[‘mn’, ‘qr’, ‘st’]
['mn', 'qr', 'st', '']
('mn', 'qr', 'st')
('mn', 'qr', 'st', '')
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What will be the output of the following Python code? *
1 point
pq+rs+tv
pq++++++++rs++++++++tv
pq rs tv
None of the mentioned
What will be the output of the following Python statement? *
1 point
Error
Option 2
x\95˜
\x95\x98
To check whether string s1 contains another string s2, use _______ *
1 point
s1.__contains__(s2)
s2 in s1
s1.contains(s2)
si.in(s2)
The output of executing string.ascii_letters can also be achieved by: *
1 point
string.ascii_lowercase_string.digits
string.ascii_lowercase+string.ascii_upercase
string.letters
string.lowercase_string.upercase
What will be the output of the following Python code? *
1 point
2
0
error
none of the mentioned
print(0xA + 0xB + 0xC): *
1 point
0xA0xB0xC
Error
0x22
33
What will be the output of the following Python statement? *
1 point
P
p
Error
b
What will be the output of the following Python code? *
1 point
error
(‘wx’, ‘yz’)
('wx', 'yz', '')
none of the mentioned
What will be the output of the following Python code? *
1 point
ow
world
he
rl
What will be the output of the following Python code snippet? *
1 point
xyzz
wxyz
xzyz
zxyz
What will be the output of the following Python code? *
1 point
2
0
1
error
What will be the output of the following Python code? *
1 point
Error
-1
4
0
What will be the output of the following Python code? *
1 point
Python fbb and fbb
Python 'fbb' and fbb
Python fbb and ‘bin’
Error
What will be the output of the following Python code snippet? *
1 point
00xy
x00y
xy00
x0y0
What will be the output of the following Python statement? *
1 point
a
q
r
Q
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What will be the output of the following Python code? *
1 point
{88: 50, 89: 51, 90: 52}
{80: 50, 81: 51, 82: 52}
432
234
What will be the output of the following Python code? *
1 point
op
mnopqr
error
none of the mentioned
What will be the output of the following Python code? *
1 point
pqr xyz
PQR XYZ
Pqr xyz
Pqr Xyz
What will be the output of the following Python code? *
1 point
mn op qr
mnopqr
mn\top\tqr
mn op qr
Suppose x is 6 and y is 4, x + y is same as ________ *
1 point
x.__add(y)
x.__add__(y)
x.__Add(y)
x.__ADD(y)
What will be the output of the following Python code? *
1 point
Python bin and fab
Python fab and bin
Error
None of the mentioned
What will be the output of the following Python code? *
1 point
error
u
t
y
What will be the output of the following Python code? *
1 point
True
2
3
None of the mentioned
What will be the output of the following Python code snippet? *
1 point
['pq', 'rs', 'tv']
[‘pq\n’, ‘rs\n’, ‘tv\n’]
[‘pq\n’, ‘rs\n’, ‘tv’]
[‘pq’, ‘rs’, ‘tv\n’]
What will be the output of the following Python code? *
1 point
0.677777
0.67
0.6777:.2
Error
What will be the output of the following Python code snippet? *
1 point
pqrs
2345
error
none of the mentioned
What will be the output of the following Python code? *
1 point
1
True
3
2
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What will be the output of the following Python code? *
1 point
True
False
Error
None of the mentioned
What will be the output of the following Python code? *
1 point
\tboo
boo
\boo
none of the mentioned
What will be the output of the following Python code? *
1 point
(‘pq’, ‘tv’)
(‘pqtv’)
('pq', 'rs', 'tv')
2
What will be the output of the following Python code? *
1 point
rs
pqrstv
error
none of the mentioned
Say s=”hello” what will be the return value of type(s)? *
1 point
int
bool
str
String
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What is “Hello”.replace(“l”, “e”)? *
1 point
Heeeo
Heelo
Heleo
None
What will be the output of the following Python code snippet? *
1 point
[‘mn’, ‘qr’, ‘st’]
['mn', 'qr', 'st', '']
('mn', 'qr', 'st',)
['mn', 'qr', 'st']
What will be the output of the following Python code? *
1 point
nthopy
python
h
n
What will be the output of the following Python code? *
1 point
0.33
40.40%
40.00%
42.00%
What will be the output of the following Python code? *
1 point
224
Error
12
None
Suppose y is 345.3546, what is format(y, “10.3f”) (_ indicates space). *
1 point
__345.355
___345.355
____345.355
_____345.354
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What will be the output of the following Python code? *
1 point
Python fff and bin
Python {0} and {1} fff bin
Error
Python 0 and 1
What will be the output of the “hello” +1+2+3? *
1 point
hello123
hello
Error
hello6
What will be the output of the following Python code? *
1 point
True
False
None
Error
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What will be the output of the following Python code snippet? *
1 point
qrst
pqrs
error
none of the mentioned
What will be the output of the following Python code? *
1 point
4
3
5
0
To return the length of string s what command do we execute? *
1 point
s.__len__()
len(s)
size(s)
s.size()
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What will be the output of the following Python code snippet? *
1 point
2,223,334,445
222,333,444,5
2223334445
Error
What will be the output of the following Python code? *
1 point
Python faa and bin
Python {name1} and {name2}
Error
Python and
What will be the output of the following Python code? *
1 point
error
rppqpqq
r
pqr
Which of the following statement prints hello\example\test.txt? *
1 point
print(“hello\example\test.txt”)
print(“hello\\example\\test.txt”)
print(“hello\”example\”test.txt”)
print(“hello”\example”\test.txt”)
Given a string example=”hello” what is the output of example.count(‘l’)? *
1 point
2
1
None
0
What will be the output of the following Python code? *
1 point
(‘mn’, ‘op’, ‘qr’, ‘st’, ‘uv’)
('mn', 'op', 'qrstuv')
(‘mnopqr’, ‘st, ‘uv’)
error
What will be the output of the following Python code snippet? *
1 point
The sum of 2 and 12 is 14
The sum of 10 and c is 16
The sum of 10 and a is c
Error
What will be the output of the following Python code snippet? *
1 point
('rs')
(")
('rs', ", ")
('', 'rs', '')
What will be the output of the following Python code? *
1 point
Python faa and bin
Python (‘faa’, ‘bin’) and (‘faa’, ‘bin’)
Error
None of the mentioned
What arithmetic operators cannot be used with strings? *
1 point
+
*
_
All of the mentioned
What will be the output of the following Python code? *
1 point
rppq
rq
rppqrqrp
none of the mentioned
What will be the output of the following Python code? *
1 point
pq rs tu
pqrstu
pq\trs\ttu
pq rs tu
What will be the output of the following Python code? *
1 point
* pqrstv*
* pqrstv *
*pqrstv*
* pqrstv *
What will be the output of the following Python code? *
1 point
SRQP
SRQP
PQRS
pqrs
What will be the output of the following Python code snippet? *
1 point
XY!@
xy12
xY!4
xY1@
What will be the output of the following Python code snippet? *
1 point
['mnopqropstop']
'mnopqropstop'
error
none of the mentioned
What will be the output of the following Python code snippet? *
1 point
pqtv
10
error
none of the mentioned
To retrieve the character at index 3 from string s=”Hello” what command do we execute
(multiple answers allowed)? *
1 point
s[]
s.getitem(3)
s.__getitem__(3)
s.getItem(3)
What will be the output of the following Python code? *
1 point
1pqrstv
pqrstv1
pqrstv
error
What will be the output of the following Python code snippet? *
1 point
3,334,445,556
333,444,555,6
3334445556
Error
What will be the output of the following Python statement? *
1 point
Error
Output equivalent to print ‘black\berry’
blackberry
black berry
What will be the output of the following Python code snippet? *
1 point
['mn', 'qr', 'stop']
[‘mn’, ‘qropstop’]
[‘qropstop’,‘mn’ ]
none of the mentioned
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What will be the output of the following Python code? *
1 point
esorder
red
rose
redrose
What will be the output of the following Python code? *
1 point
xyz
'xyz'
b’xyz’
h’xyz’
What function do you use to read a string? *
1 point
input(“Enter a string”)
eval(input(“Enter a string”))
enter(“Enter a string”)
eval(enter(“Enter a string”))
What will be the output of the following Python code? *
1 point
None None
None 22
22 None
Error is generated
What will be the output of the following Python code? *
1 point
2
0
1
error
What will be the output of the following Python statement?(python 3.xx) *
1 point
Python# 100#900.66
Python#100# 900.67
Python # 100#900.67
Python#100#900.67
What will be the output of the following Python code snippet? *
1 point
Pq rs-tu
Pq Rs-tu
Pq Rs-Tu
None of the mentioned
What will be the output of the following Python code? *
1 point
True
False
None
Error
What will be the output of the following Python code? *
1 point
Python fff and bin
Python {name1} and {name2}
Error
Python and
What will be the output of the following Python code snippet? *
1 point
0+88
0088
+088
++88
What will be the output of the following Python code? *
1 point
True
False
None
Error
What will be the output of the following Python code? *
1 point
* mnopqr*
*mnopqr*
* mnopqr *
* mnopqr *
What is the default value of encoding in encode()? *
1 point
ascii
qwerty
utf-8
utf-16
What will be the output of the following Python code? *
1 point
{120: 50, 121: 51, 122: 52}
{97: 49, 98: 50, 99: 51}
{100: 50, 101: 51, 102: 52}
234
What will be the output of the following Python code? *
1 point
12mnopqr12
mnopqr1212
1212mnopqr
error
What will be the output of the following Python code? *
1 point
* pqrst *
*pqrst *
*pqrst*
* pqrst *
What will be the output of the following Python code snippet? *
1 point
pq1tvo
pqrtvs
pq1tvs
pq12ts2
What will be the output of the following Python code? *
1 point
2
0
1
none of the mentioned
What will be the output of the following Python code snippet? *
1 point
(‘pqtv’)
(‘pqtv’, ‘rs’, ”)
('pqtv', '', '')
error
If a class defines the __str__(self) method, for an object obj for the class, you can use which
command to invoke the __str__ method. *
1 point
obj.__str__()
str(obj)
print obj
all of the mentioned
What will be the output of the following Python code snippet? *
1 point
True
False
None
Error
What will be the output of the following Python code? *
1 point
0
1
True
False
The format function, when applied on a string returns ________ *
1 point
Error
int
bool
str
Part D : List 1
*Obligatoire
To remove string "red" from list1, use _______. *
1 point
list1.remove("red")
list1.remove(red)
list1.removeAll("red")
list1.removeOne("red")
What will be the output of the following code snippet? *
1 point
[2] [3] [4]
123
[2, 3, 4]
[2] [2, 3] [2, 3, 4]
Let list1 = [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.extend([34, 5])? *
1 point
[3, 4, 5, 20, 5, 25, 1, 3, 34, 5]
[1, 3, 3, 4, 5, 5, 20, 25, 34, 5]
[25, 20, 5, 5, 4, 3, 3, 1, 34, 5]
[1, 3, 4, 5, 20, 5, 25, 3, 34, 5]
[3, 1, 25, 5, 20, 5, 4, 3, 34, 5]
Let list1 = [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)? *
1 point
[3, 4, 5, 20, 5, 25, 1, 3]
[1, 3, 3, 4, 5, 5, 20, 25]
[3, 5, 20, 5, 25, 1, 3]
[1, 3, 4, 5, 20, 5, 25]
[3, 1, 25, 5, 20, 5, 4]
Let list1 = [3, 4, 5, 18, 5, 22, 1, 2], what is len(list1)? *
1 point
6
7
8
5
4
Let list1 = [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.reverse()? *
1 point
[3, 4, 5, 20, 5, 25, 1, 3]
[1, 3, 3, 4, 5, 5, 20, 25]
[25, 20, 5, 5, 4, 3, 3, 1]
[1, 3, 4, 5, 20, 5, 25, 3]
[3, 1, 25, 5, 20, 5, 4, 3]
Let list1 = [3, 4, 5, 20, 5, 25, 1, 3], what is max(list1)? *
1 point
5
4
8
25
1
Let list1 = [3, 2, 5, 10, 5, 24, 1, 3], what is min(list1)? *
1 point
5
4
8
25
1
__________ creates a list. *
1 point
list1 = list()
list1 = []
list1 = list([12, 4, 4])
list1 = [12, 4, 4]
list1 = [1, "3", "red"]
What will be the output of the following code snippet? *
1 point
[1, 2, 3, 33]
[1, 2, 3]
[1, 33]
[33, 2, 3]
"Welcome to Python".split() is ________ *
1 point
["Welcome", "to", "Python"]
("Welcome", "to", "Python")
{"Welcome", "to", "Python"}
"Welcome", "to", "Python"
To add 5 to the end of list1, use _______. *
1 point
list1.add(5)
list1.append(5)
list1.addLast(5)
list1.addEnd(5)
What Will be The output Of the following code snippet? *
1 point
11
1 33
31
3 33
Let list1 = [0.5 * a for a in range(0, 4)], list1 is ________ *
1 point
[0, 1, 2, 3]
[0, 1, 2, 3, 4]
[0.0, 0.5, 1.0, 1.5]
[0.0, 0.5, 1.0, 1.5, 2.0]
What is the output when we execute list(“hello”)? *
1 point
[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
[‘hello’]
[‘llo’]
[‘olleh’]
Let list1 = [2, 3, 4], What is list1 * 2? *
1 point
[2, 6, 4]
[2, 4, 3, 2, 4]
[2, 3, 4, 2, 3, 4]
[2, 3, 4, 4, 3, 2]
To shuffle list1, use _______. *
1 point
list1.shuffle()
shuffle(list1)
random.shuffle(list1)
random.shuffleList(list1)
Let list1 = [1, 3, 2, 4, 5, 2, 1, 0], What is list1[-1]? *
1 point
3
5
1
0
list1 = [11, 2, 23] and list2 = [11, 2, 2], list1 < list2 is ________ *
1 point
True
False
What Will be The output Of the following code snippet? *
1 point
0
1
2
3
4
list1 = [11, 2, 23] and list2 = [2, 11, 23], list1 == list2 is ________ *
1 point
True
False
Let list1 = [1, 3, 2, 4, 5, 2, 1, 0], What is list1[:-1]? *
1 point
0
[1, 3, 2, 4, 5, 2, 1]
[1, 3, 2, 4, 5, 2]
[1, 3, 2, 4, 5, 2, 1, 0]
What will be the output of the following code snippet? *
1 point
[2, 3]
[1, 3]
[3, 2]
[1, 2, 3]
What is list("pqrs")? *
1 point
['p', 'q', 'r', 's']
['pq']
['rs']
['pqrs']
What is list("a#b#c#d".split('#'))? *
1 point
['a', 'b', 'c', 'd']
['a b c d']
['a#b#c#d']
['abcd']
Let list1 = [0, 3, 2], what is sum(list1)? *
1 point
5
4
6
2
1
What will be the output of the following code snippet? *
1 point
234561
112345
612345
12344
Let list1 = [3, 4, 5, 20, 5, 25, 1, 3], what is list1.index(5)? *
1 point
0
4
1
2
Let list1 = [1, 3, 2, 4, 5, 2, 1, 0], Which of the following is correct? *
1 point
print(list1[0])
print(list1[:2])
print(list1[:-2])
print(list1[4:6])
To insert 5 to the third position in list1, use _______. *
1 point
list1.insert(3, 5)
list1.insert(2, 5)
list1.add(3, 5)
list1.append(3, 5)
Let list1 = [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.sort()? *
1 point
[3, 4, 5, 20, 5, 25, 1, 3]
[1, 3, 3, 4, 5, 5, 20, 25]
[25, 20, 5, 5, 4, 3, 3, 1]
[1, 3, 4, 5, 20, 5, 25, 3]
Let list1 = [3, 4, 5, 20, 5, 25, 1, 3], what is list1.count(5)? *
1 point
0
4
1
2
Part E :
Python List-II
*Obligatoire
What will be the output of the following code? *
1 point
[5,8]
[]
[5, 7]
Invalid arguments for filter function
What will be the output of the following code? *
1 point
[(‘P’, 1), (‘Y’, 1), (‘T’, 1), (‘H’, 1), (‘O’, 1), (‘N’, 1)]
[(‘PYTHON’, 5)]
[('P', 1), ('Y', 1), ('T', 1), ('H', 1), ('O', 1), ('N', 1)]
Syntax error
Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing
operation? *
1 point
print(list1[0])
print(list1[:2])
print(list1[:-2])
all of the mentioned
What will be the output of the following code? *
1 point
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[[0, 2, 3], [1, 3, 4], [2, 4, 5]]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 1, 2, 3, 2, 3, 4]
What will be the output of the following code? *
1 point
6
5
4
22
What will be the output of the following code? *
1 point
1
3
2
None
What will be the output of the following code? *
1 point
[1, 4, 3]
[2, 4, 6, 5]
[ 2, 4, 5]
[ 2, 4, 6]
What will be the output of the following code? *
1 point
("Welcome", "to", "Python")
{"Welcome", "to", "Python"}
['Welcome', 'to', 'Python']
"Welcome", "to", "Python"
What will be the output of the following code? *
1 point
2
5
4
6
What will be the output of the following code? *
1 point
1: 2: 3:
Exception is thrown
One Two Three
0: One 1: Two 2: Three
What will be the output of the following code? *
1 point
['2, 4, 6']
[2] [ 2, 4] [2, 4, 6]
[2, 4, 6]
[2] [4] [6]
What will be the output of the following Python code? *
1 point
5
3
4
0
What will be the output of the following code? *
1 point
b
m
d
None
What will be the output of the following code? *
1 point
2234336334523445455
2234334544523423345
22345233452344523455
22234522223453452345
What will be the output of the following code? *
1 point
2345
5678
2 3 9 15
3 6 10 14
What will be the output of the following code? *
1 point
10
12
2
8
What will be the output of the following code? *
1 point
False
True
Error
None
Suppose list1 = [0.5 * x for x in range(0, 5)], list1 is: *
1 point
[1.0, 0.5, 0.0, 1.5, 2.0]
[0.0, 0.5, 1.0, 1.5, 2.0]
[2.0, 1.5, 1.0, 0.5, 0.0]
[0.1, 0.2, 0.3, 0.4, 0.5]
What will be the output of the following code? *
1 point
[[4, 2.5], [2, 3], [0.7, 0.7]]
[[0.7, 0.7], [2, 3], [4, 2.5]]
[[0.7, 0.7], [4, 2.5], [2, 3]]
[[2, 3], [4, 2.5], [0.7, 0.7]]
What will be the output of the following code? *
1 point
Option 1
Option 2
Option 3
Option 4
What will be the output of the following code? *
1 point
['mango', 'berry', 'apple', 'banana', 'cherry']
['mango', 'berry', 'banana', 'cherry']
['mango', 'apple', 'berry', 'banana', 'cherry']
['mango', 'apple', 'berry', 'cherry' 'banana' ]
What will be the output of the following code? *
1 point
Syntax error
[[5], [], []]
[[5], [5], [5]]
[[],5, [], []]
What will be the output of the following code? *
1 point
[‘Mango’, ‘Nail’, ‘Ox’]
['Ox', 'Nail', 'Mango']
['Ox', 'Mango', 'Nail' ]
Invalid syntax for sort()
What will be the output of the following code? *
1 point
14
[2,3,5,7]
5
[2, 5, 9, 14]
What will be the output of the following code? *
1 point
14
[2,5,7,9]
[2, 5, 9, 14]
[2,3,9,14]
What will be the output of the following code? *
1 point
[20,33,60,[90]]
[20,33,60,[80]]
[20, 33, 60, [80]]
[20, 33, 60, [90]]
What will be the output of the following code? *
1 point
[2] [3]
[49] [50]
[[2]] [[3]]
Syntax error
What will be the output of the following code? *
1 point
[20,33,60,[90]]
[20, 33, 60, [88]]
[20, 33, 60, [90]]
[20,33,60,[88]]
What will be the output of the following code? *
1 point
True
False
What will be the output of the following code? *
1 point
A
Dhiman
Error
n
What will be the output of the following code? *
1 point
Error
[2,5]
[7]
7
What will be the output of the following code? *
1 point
5
1
4
8
What will be the output of the following code? *
1 point
[12,48,15, [77]40,60]
[12, 48, 15, [77], 40, 60]
[12, 48, 15, 77,[ 40, 60]]
[12,48,15,77,[ 40, 60]]
What will be the output of the following code? *
1 point
2
8
4
6
What will be the output of the following code? *
1 point
561
12
8
Syntax error
How many elements are in a? *
1 point
[[0, 1], [0, 2], [2, 0], [0, 1]]
[[0, 0], [0, 1], [1, 0], [1, 1]]
[[0, 10], [0, 2], [0, 3], [0, 4]]
None
What will be the output of the following code? *
1 point
Return a list containing every third item from L starting at index 0
Return an empty list
Return a list containing every third index from L starting at index 0
Return a list containing the items from L starting from index 0, omitting every third item
What will be the output of the following code? *
1 point
[4, 8, 9, 7, 2, 3]
Syntax error
[4,[8,9],5,2,3]
[4,5,6,7,8]
What will be the output of the following code? *
1 point
Option 1
Option 2
Option 3
Syntax error
What will be the output of the following code? *
1 point
2
4
5
6
What will be the output of the following code? *
1 point
[2, 5]
[5, 2]
[3, 5]
[5, 3]
What will be the output of the following code? *
1 point
Option 1
Option 2
Option 3
Syntax error
What is the maximum number of elements List can contain in Python? *
1 point
10 million items
10 million on 32-bit system and 20 million on 64-bit system
There is no limit
20 million items
Another limit
What will be the output of the following code? *
1 point
Option 1
Option 2
Option 3
Option 4
What will be the output of the following code? *
1 point
2
3
6
7
What will be the output of the following code? *
1 point
1
2
3
4
What will be the output of the following code? *
1 point
3 44
4 44
5 44
67
Suppose list1 is [3, 4, 15, 15, 25, 15], what is list1.index(15)? *
1 point
0
5
2
3
What will be the output of the following code? *
1 point
66234
62345
34562
34566
What will be the output of the following code? *
1 point
[ 45, 6, 4,]
[45, 4]
[4, 6, 45 ]
[45, 4, 6]
What will be the output of the following code? *
1 point
Option 1
Option 2
Option 3
Option 4
To which of the following the “in” operator can be used to check if an item is in it? *
1 point
Dictionary
Set
Lists
All of the above
What will be the output of the following code? *
1 point
Option 1
Option 2
Option 3
Syntax error
What will be the output of the following code? *
1 point
The program prints two rows 3 5 6 2 followed by 44 7 2 3
The program prints on row 3 6 5 2 44 7 3 2
The program prints two rows 2 4 5 6 followed by 2 3 7 44
The program prints two rows 3 6 5 2 followed by 44 6 2 3
What will be the output of the following code? *
1 point
5
6
44
7
What will be the output of the following code? *
1 point
[[3],[8]]
[2, 3, 4, 5]
Error
[14]
Which of the following commands will create a list? *
1 point
list1 = []
list1 = list()
list1 = list([1, 2, 3])
all of the mentioned
What will be the output of the following code? *
1 point
['Monkey', 'Fox', 'Deer']
['Monkey', 'Fox', 'Lion']
['Monkey', 'Fox', 'Tiger']
['Monkey', 'Tiger', 'Lion']
What will be the output of the following code? *
1 point
None [4, 6, 8]
[4,6,8] None
[1, 2, 3] [4,5,6]
None [1, 2, 3]