Exercise: Standard Libraries

Questions for: Standard Libraries

Which module in Python is used for working with the operating system, providing a way to execute shell commands?
A:
os
B:
system
C:
shell
D:
command
Answer: A
The os module in Python provides a way to interact with the operating system, including functions to execute shell commands.
What is the purpose of the collections module?
A:
Mathematical operations
B:
Working with collections (lists, tuples, sets, etc.)
C:
File I/O operations
D:
Web development
Answer: B
The collections module in Python provides specialized data types and functions to work with collections, such as namedtuple, Counter, and defaultdict.
Which function is used to retrieve the keys of a dictionary?
A:
dict.keys()
B:
dict.get_keys()
C:
dict.extract_keys()
D:
dict.getkeys()
Answer: A
The keys() method is used to retrieve the keys of a dictionary in Python.
Which module in Python is commonly used for working with regular expressions but has a simpler API compared to re?
A:
regex
B:
regexp
C:
relib
D:
regexlib
Answer: A
The regex module in Python provides a simpler API for working with regular expressions, offering additional features and improvements over the standard re module.
Which module in Python provides functionality to work with compressed files, such as ZIP files?
A:
gzip
B:
zipfile
C:
compress
D:
archive
Answer: B
The zipfile module in Python provides tools for creating, reading, and extracting ZIP files.
Ad Slot (Above Pagination)
Quiz