Python Programming - Standard Libraries
Exercise : Standard Libraries - General Questions
- Standard Libraries - General Questions
1.
What is the purpose of the
sys
module?
Answer: Option
Explanation:
The
sys
module provides access to some variables used or maintained by the Python interpreter and functions that interact strongly with the interpreter. It is often used for accessing command line arguments, interacting with the Python runtime environment, and more.
2.
Which module is commonly used for working with regular expressions?
Answer: Option
Explanation:
The
re
module in Python is used for working with regular expressions, allowing you to search, match, and manipulate strings based on specified patterns.
3.
Which function is used to open a file for writing?
Answer: Option
Explanation:
To open a file for writing in Python, you use the
open()
function with the mode parameter set to "w" (write). For example: file = open("file.txt", "w")
4.
What does the
random.choice()
function do?
Answer: Option
Explanation:
The
random.choice()
function in Python is used to pick a random element from a sequence, such as a list or tuple.
5.
What is the purpose of the
json.dumps()
function?
Answer: Option
Explanation:
The
json.dumps()
function is used to encode Python objects into a JSON-formatted string, allowing you to serialize data for storage or transmission.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers