TechnologyProfessionTest
Sort by
Newest
Most popular
Last review
Filter by
Published
6
Not published
0
To review
4
TechnologyProfessionTest
Sort by
Newest
Most popular
Last review
Filter by
Published
6
Not published
0
To review
4
10 questions
Medium
1 vote44 runs0 comment
Easy
0 vote205 runs0 comment
Hard
0 vote99 runs0 comment
Medium
0 vote97 runs0 comment
Hard
0 vote97 runs0 comment
Easy
0 vote47 runs0 comment
Waiting for validation
0 vote0 run0 comment
Consider both of these asynchronous functions: ```python async def second_function(): requests.get('http://example.com') print('Second function iteration') async def first_function(): requests.get('http://example.com') print('First function iteration') ``` Would you say that the logic behind `first_main` and `second_main` are equivalent to one another? ```python async def first_main(): tasks = [ asyncio.create_task(first_function()), asyncio.create_task(second_function()) ] for task in asyncio.as_completed(tasks): await task ``` ```python async def second_main(): await asyncio.gather(first_function(), second_function()) ``` __Find all the correct answers__
John Pendenqueat Oct 6, 2025
Waiting for validation
0 vote0 run0 comment
What does the variable `tg` represent in the `first_function` and within the context of the `main` function in the code below that uses `asyncio.TaskGroup`? ```python import asyncio async def second_function(): for _ in range(5): print('Second function iteration') await asyncio.sleep(1) async def first_function(tg: asyncio.TaskGroup): for _ in range(5): tg.create_task(second_function()) print('First function iteration') await asyncio.sleep(5) async def main(): async with asyncio.TaskGroup() as tg: task1 = tg.create_task(first_function(tg)) await task1 asyncio.run(main()) ```
John Pendenqueat Oct 6, 2025
Waiting for validation
0 vote0 run0 comment
What can be asserted about the unittest code below? ```python import unittest from unittest.mock import MagicMock, patch import requests class TestSimpleTest(unittest.TestCase): def test_request(self): with patch('requests.get') as mock_get: mock_response = MagicMock() mock_response.status_code = 200 mock_get.return_value = mock_response response = requests.get('https://example.com') self.assertEqual(response.status_code, 200) ```
John Pendenqueat Oct 6, 2025
Waiting for validation
0 vote0 run0 comment
Consider the two asynchronous functions below: ```python import asyncio async def second_function(): for _ in range(5): print('Second function iteration') await asyncio.sleep(3) async def first_function(): for _ in range(5): print('First function iteration') await asyncio.sleep(5) async def main(): task1 = asyncio.create_task(first_function()) task2 = asyncio.create_task(second_function()) await task1 await task2 asyncio.run(main()) ``` What can you say about the order of execution of these two functions?
John Pendenqueat Oct 6, 2025