Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Lists and operators

Total questions: 15

Worksheet time: 11mins

Name
Class
Date
1.

Logical AND operator returns true if?

a)

Both operands are true

b)

Either operand is true

c)

Both operands are false

d)

None of the above

2.

Which of the following operators checks for the equality of two operands

a)

=

b)

==

c)

Both

d)

None

3.

Operands of the logic operator must be of which type?

a)

Numeric

b)

Boolean

c)

String

d)

All of the above

4.

What will be the output of the following code?

nums = list({1:'one',2:'two'})

print(nums)

a)

Syntax error

b)

[1,2]

c)

['one','two']

d)

Runtime error

5.

Which of the following is an invalid list object?

a)

list(“Hello”)

b)

[10, 1.235+5j, ‘python’]

c)

[(1,2), (3,4)]

d)

All are valid

6.

The list.pop() function wil'

a)

Remove first element from the list

b)

Remove last element from the list

c)

  Add an element to the list

d)

Will delete the list

7.

What will be the output of the following code?

    x = x[x for x in range of 10 if x<5]

print (x)

a)

[1,2,3,4,5]

b)

[]

c)

[5,6,7,8,9]

d)

[0,1,2,3,4]

8.

What will the output of the following code?

lst = [1,2,3,4,5]

print(lst[0:1])

a)

[1,2,3,4,5]

b)

[]

c)

[1]

d)

syntax error

9.

What will be the output of the following snippet?

lst = ['python', 'java','c++','SQL']

lst.insert(len(l1),'SQL')

print(lst)

a)

[‘Python’, ‘JAVA’, ‘C++’, ‘SQL’]

b)

[‘SQL’, ‘Python’, ‘JAVA’, ‘C++’]

c)

[‘Python’, ‘JAVA’, ‘SQL’, ‘C++’]

d)

[‘Python’, ‘SQL’ , ‘JAVA’, ‘C++’]

10.

What will be the output of following code snippet

names= ('jeff','Bill','steve','yash')

a,b,c,d = names

print("Hello",a)

a)

Hello  Jeff

b)

Hello Yash

c)

Hello

d)

None of the above

11.

To delete a key value pair in dictionary, use

a)

del() method

b)

pop() method

c)

del keyword

d)

remove()

12.

Which of the following statements is true

a)

Dictionary is the sequence of key-value pairs

b)

Dictionary is an indexed collection of key-value pairs

c)

Dictionary is an un ordered collection of key-value pairs

d)

None of these

13.

The items() from the dictionary returns

a)

list of tuples

b)

tuples of tuples

c)

tuple of lists

d)

none of the above

14.

What will be the output of the following code?

years = {1995: 'java',1994:'python',1993:'c++'}

print(years.get(2000))

a)

value error

b)

syntax error

c)

blank output

d)

java

15.

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?

a)

List of years

b)

List of languages

c)

List of tuples each having year and language

d)

None of these