WorksheetsLists and operators
Total questions: 15
Worksheet time: 11mins
Logical AND operator returns true if?
Both operands are true
Either operand is true
Both operands are false
None of the above
Which of the following operators checks for the equality of two operands
=
==
Both
None
Operands of the logic operator must be of which type?
Numeric
Boolean
String
All of the above
What will be the output of the following code?
nums = list({1:'one',2:'two'})
print(nums)
Syntax error
[1,2]
['one','two']
Runtime error
Which of the following is an invalid list object?
list(“Hello”)
[10, 1.235+5j, ‘python’]
[(1,2), (3,4)]
All are valid
The list.pop() function wil'
Remove first element from the list
Remove last element from the list
Add an element to the list
Will delete the list
What will be the output of the following code?
x = x[x for x in range of 10 if x<5]
print (x)
[1,2,3,4,5]
[]
[5,6,7,8,9]
[0,1,2,3,4]
What will the output of the following code?
lst = [1,2,3,4,5]
print(lst[0:1])
[1,2,3,4,5]
[]
[1]
syntax error
What will be the output of the following snippet?
lst = ['python', 'java','c++','SQL']
lst.insert(len(l1),'SQL')
print(lst)
[‘Python’, ‘JAVA’, ‘C++’, ‘SQL’]
[‘SQL’, ‘Python’, ‘JAVA’, ‘C++’]
[‘Python’, ‘JAVA’, ‘SQL’, ‘C++’]
[‘Python’, ‘SQL’ , ‘JAVA’, ‘C++’]
What will be the output of following code snippet
names= ('jeff','Bill','steve','yash')
a,b,c,d = names
print("Hello",a)
Hello Jeff
Hello Yash
Hello
None of the above
To delete a key value pair in dictionary, use
del() method
pop() method
del keyword
remove()
Which of the following statements is true
Dictionary is the sequence of key-value pairs
Dictionary is an indexed collection of key-value pairs
Dictionary is an un ordered collection of key-value pairs
None of these
The items() from the dictionary returns
list of tuples
tuples of tuples
tuple of lists
none of the above
What will be the output of the following code?
years = {1995: 'java',1994:'python',1993:'c++'}
print(years.get(2000))
value error
syntax error
blank output
java
years= {1995:'java',1994:'python',1993:'c++'}
is a dictionary witha key value pairs with year of invention and name of the language. The expresion list(years) will return?
List of years
List of languages
List of tuples each having year and language
None of these
