NEW
Font size
WorksheetsPython Viva Questions
Total questions: 15
Worksheet time: 8mins
What is the output of the following code snippet?
my_list = [1, 2, 3, 4, 5]
my_list.append(6)
print(my_list)
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, [6]]
[1, 2, 3, 4, 5, (6)]
Which of the following statements is true about tuples in Python?
Tuples are mutable.
Tuples are ordered.
Tuples can have duplicate elements.
Tuples use curly braces {} for initialization.
What is the purpose of a Python dictionary?
To store data in an ordered sequence.
To store data as key-value pairs.
To store data in a sorted manner.
To store data in a linear structure.
Which of the following methods in Python is used to find the length of a string?
length()
count()
size()
len()
What will be the output of the following code snippet?
x = 10
if x > 5:
print("Greater than 5")
else:
print("Less than or equal to 5")
"Greater than 5"
"Less than or equal to 5"
"x is equal to 5"
"x is greater than 10"
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
\l
/
\\n
\n
Which is the most appropriate data type for: "13th December"
String
Boolean
Float
Integer
print("12"*3)
What would this print?
121212
36
24
12*3
What will be the output of the following code snippet?
my_dict = {'a': 1, 'b': 2}
my_dict['c'] = 3
print(my_dict)
{'a': 1, 'b': 2}
{'a': 1, 'b': 2, 'c': 3}
{'a': 1, 'b': [2], 'c': 3}
{'a': 1, 'b': 2, 'c': (3)}
What is the result of the expression: "Hello" + " World"?
Hello World
"Hello World"
"Hello" + " World"
HelloWorld
Which of the following statements is true about lists in Python?
Lists are immutable.
Lists can contain elements of different data types.
Lists use parentheses () for initialization.
Lists cannot be nested.
What will be the output of the following code snippet?
a = [1, 2, 3]
a[1] = 4
print(a)
[4, 2, 3]
[1, 2, 4]
[1, 4, 3]
[1, 2, 3]
Which of the following methods can be used to remove an item from a list in Python?
delete()
remove()
discard()
popitem()
What is the method used to retrieve a value from a Python dictionary using a key?
retrieve()
fetch()
access()
get()
What will be the output of the following code snippet?
my_tuple = (1, 2, 3)
print(my_tuple[0])
2
Error
3
1
