Python Programming - Standard Libraries
Exercise : Standard Libraries - General Questions
- Standard Libraries - General Questions
61.
What is the purpose of the
collections.namedtuple()
function?
Answer: Option
Explanation:
The
collections.namedtuple()
function in Python is used to create named tuples with named fields.
62.
Which module in Python provides functions for working with regular expressions in a more advanced and powerful manner than the
re
module?
Answer: Option
Explanation:
The
regex
module in Python provides functions for working with regular expressions in a more advanced and powerful manner than the re
module.
63.
What does the
multiprocessing
module in Python provide?
Answer: Option
Explanation:
The
multiprocessing
module in Python provides functions and classes for working with multiprocessing, allowing the execution of parallel processes.
64.
How can you use the
collections.Counter
class in Python to count the occurrences of elements in a list?
Answer: Option
Explanation:
from collections import Counter
# Example usage of collections.Counter
my_list = [1, 2, 3, 1, 2, 1, 4, 5, 4, 3, 2]
element_counts = Counter(my_list)
print(element_counts)
65.
Which module in Python provides support for working with regular expressions in a more advanced and powerful manner than the
re
module?
Answer: Option
Explanation:
import regex as re
# Example usage of regex module
pattern = re.compile(r'\b(\w+)\b')
text = "This is a sample text."
matches = pattern.findall(text)
print(matches)
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers