Python Programming - Standard Libraries
Exercise : Standard Libraries - General Questions
- Standard Libraries - General Questions
66.
Which module in Python provides support for working with asynchronous I/O operations?
Answer: Option
Explanation:
import asyncio
# Example usage of asyncio for asynchronous I/O
async def main():
print("Hello")
await asyncio.sleep(1)
print("World")
asyncio.run(main())
67.
What is the purpose of the
json
module?
Answer: Option
Explanation:
import json
# Example usage of json module for parsing JSON data
json_data = '{"name": "John", "age": 30, "city": "New York"}'
parsed_data = json.loads(json_data)
print(parsed_data)
68.
How can you use the
random
module in Python to generate a random integer between 1 and 10 (inclusive)?
Answer: Option
Explanation:
import random
# Example usage of random module
random_number = random.randint(1, 10)
print(f"Random number: {random_number}")
69.
What is the purpose of the
math
module?
Answer: Option
Explanation:
import math
# Example usage of math module
result = math.sqrt(25)
print(f"Square root: {result}")
70.
How can you use the
urllib.request
module in Python to make an HTTP GET request to a URL?
Answer: Option
Explanation:
import urllib.request
# Example usage of urllib.request module for making an HTTP GET request
url = 'https://www.example.com'
response = urllib.request.urlopen(url)
content = response.read()
print(content)
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers