wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Week 3-4

Total questions: 25

Worksheet time: 9mins

Name
Class
Date
1.

What is the output of min([5, 3, 8])?

a)

8

b)

5

c)

3

d)

None

2.

Which statement about a dictionary is correct?

a)

Keys must be immutable

b)

Keys can be mutable

c)

Values must be immutable

d)

Values cannot be duplicated

3.

What does the "symmetric_difference()" method do in sets?

a)

Finds the common elements between two sets

b)

Finds the difference between two sets

c)

Finds elements not shared by two sets

d)

None of the above

4.

Which method is used to combine two sets?

a)

union()

b)

combine()

c)

append()

d)

add()

5.

What does "tuple()" do?

a)

Converts a list into a tuple

b)

Converts a tuple into a list

c)

Converts a string into a list

d)

None of the above

6.

What does the "clear()" method do in a dictionary?

a)

Deletes all elements in a dictionary

b)

Deletes a specific key-value pair

c)
  • Creates a new dictionary

d)
  • None of the above

7.

How do you check if a key exists in a dictionary?

a)

key in dictionary

b)

dictionary.has_key(key)

c)

dictionary.contains(key)

d)

dictionary.key_exists(key)

8.

What method is used to write data to a file in binary format?

a)

write_binary()

b)

write()

c)

wb()

d)

writefile()

9.

Which symbol is used to separate values in a CSV file?

a)

Semicolon

b)

Comma

c)

Colon

d)

Space

10.

Which of the following can be converted into JSON strings?

a)

list

b)
  • tuple

c)
  • dictionary

d)
  • All of the above

11.

What will "os.remove()" do?

a)
  • Rename a file

b)

Delete a file

c)

Create a file

d)
  • Move a file

12.

Which Python function is used to convert a Python dictionary into a JSON string?

a)

json.loads()

b)

json.dumps()

c)

json.dump()

d)

json.load()

13.

What is the default file access mode when using the "open()" function?

a)

"r"

b)

"w"

c)

"a"

d)

None

14.

Which module in Python is used to work with JSON data?

a)
  • csv

b)

json

c)
  • os

d)

file

15.

What is the purpose of the "csv.reader()" function?

a)

To write data into a CSV file

b)

To read data from a CSV file

c)

To delete a CSV file

d)

None of the above

16.

What does the os.getcwd() function do?

a)

Changes the current working directory

b)

Returns the current working directory

c)
  • Deletes the current working directory

d)
  • None of the above

17.

Which method is used to sort a list in ascending order?

a)

sorted()

b)

sort()

c)
  • arrange()

d)
  • organize()

18.

What will the expression my_list[-1] return?

a)
  • The first element of the list

b)
  • The last element of the list

c)

None

d)

IndexError

19.

How do you check if an element exists in a list?

a)
  • list.contains(element)

b)
  • element in list

c)
  • list.has(element)

d)
  • list.find(element)

20.

What is the format for slicing a list?

a)

a) list[start:end]

b)

b) list[start:end:step]

c)

c) Both a and b

d)

d) None of the above

21.

Which method removes the first occurrence of a specific item in a list?

a)
  • pop()

b)
  • remove()

c)
  • del

d)
  • discard()

22.

Which operator can be used to find the union of two sets?

a)

|

b)

&

c)

-

d)

^

23.

What does the len() function return when applied to a list?

a)

The number of elements in the list

b)

The last element of the list

c)

The size of the list in bytes

d)

None of the above

24.

Which method is used to add an element to the end of a list?

a)

append()

b)

insert()

c)

add()

d)

extend()

25.

What is the primary difference between a list and a tuple in Python?

a)

Lists are mutable, while tuples are immutable

b)

Tuples are mutable, while lists are immutable

c)

Both are mutable

d)

Both are immutable