import math
# Example usage of math module
result = math.sqrt(25)
print(f"Square root: {result}")
Discuss About this Question.
How can you use the random module in Python to generate a random integer between 1 and 10 (inclusive)?
A:
random.randint(1, 10)
B:
random.int(1, 10)
C:
rand.randint(1, 10)
D:
rand.random(1, 10)
Answer:A
import random
# Example usage of random module
random_number = random.randint(1, 10)
print(f"Random number: {random_number}")
Discuss About this Question.
What is the purpose of the json module?
A:
Working with binary data
B:
Parsing JSON data
C:
Handling dates and times
D:
Sorting elements in a list
Answer:B
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)
Discuss About this Question.
Which module in Python provides support for working with asynchronous I/O operations?
A:
asyncio
B:
asyncioio
C:
asyncioioops
D:
asyncops
Answer:A
import asyncio
# Example usage of asyncio for asynchronous I/O
async def main():
print("Hello")
await asyncio.sleep(1)
print("World")
asyncio.run(main())
Discuss About this Question.
Which module in Python provides support for working with regular expressions in a more advanced and powerful manner than the re module?
A:
regexlib
B:
advancedre
C:
relib
D:
regex
Answer:D
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)
Discuss About this Question.
Ad Slot (Above Pagination)
Install ExamAdept
Fast access — add this app to your device.
To install on iPhone/iPad: tap Share → Add to Home Screen.
Discuss About this Question.