Python Programming - Standard Libraries
Exercise : Standard Libraries - General Questions
- Standard Libraries - General Questions
86.
What is the purpose of the
csv
module?
Answer: Option
Explanation:
import csv
# Example usage of csv module for reading from a CSV file
with open('data.csv', 'r') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
print(row)
87.
How can you use the
xml.etree.ElementTree
module in Python to parse an XML file?
Answer: Option
Explanation:
import xml.etree.ElementTree as ET
# Example usage of xml.etree.ElementTree module for parsing an XML file
tree = ET.parse('data.xml')
root = tree.getroot()
for element in root:
print(element.tag, element.attrib)
88.
What is the purpose of the
collections.defaultdict
class?
Answer: Option
Explanation:
from collections import defaultdict
# Example usage of collections.defaultdict
default_dict = defaultdict(int)
default_dict['a'] += 1
default_dict['b'] += 2
print(default_dict)
89.
How can you use the
platform
module in Python to get the Python version information?
Answer: Option
Explanation:
import platform
# Example usage of platform module for getting Python version information
python_version = platform.python_version()
print(f"Python version: {python_version}")
90.
What does the
codecs
module in Python provide support for?
Answer: Option
Explanation:
import codecs
# Example usage of codecs module for encoding and decoding text
text = "Hello, World!"
encoded_text = codecs.encode(text, 'rot_13')
decoded_text = codecs.decode(encoded_text, 'rot_13')
print(decoded_text)
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers