jeudi 29 novembre 2018

Test in Python, you need to choose the correct statement

Question 1 Fork system call

1.used to get the pid of the parent process

2.used to call functions in separate threads

3.ed to create a child process

4.creates an exact copy of the parent process

 Question 2 Fork system call

  1. in the parent process, calling the fork returns the pid of the child
  2. in the child process, calling fork returns 0
  3. in the child process, calling fork returns the pid of the parent process
  4. in the parent process, the call to fork returns 0

     Question 3 What happens to the memory in the child process when working with Python?

  5. Copied from parent process

  6. Shared with parent process

Question 4 File Descriptors in the child process

  1. will be rediscovered by the Python interpreter automatically
  2. will be unavailable, they need to be rediscovered
  3. will be copied and rediscovered
  4. will be copied

     Question 5 Highlight true expressions:

  5. it is preferable to use the context manager to work with locks in Python

  6. locks must be taken in the same order, released in an arbitrary
  7. locks must be taken in the same order, released strictly in the same manner
  8. locks must be taken in the same order, released in reverse

     Question 6 Queues slow down the workflow of Python threads, better use blocking objects

  9. Not

  10. Yes

     Question 7 Highlight true expressions:

  11. GIL slows down the execution of the main control flow in Python3, even if there are no other threads.

  12. GIL does not affect the execution of individual processes in Python3.
  13. GIL prohibits simultaneous execution of bytecode instructions in different streams.
  14. GIL is needed to protect the interpreter's memory from damage

. Question 8 If a Python program performs many I / O operations (IO-bound), then to speed up its work you need

  1. break it into separate functions, execute them in streams
  2. create separate processes

     Question 9 If a Python program performs calculations that require only a CPU (CPU-bound), then to speed up its work,

  3. break it into separate functions, execute them in streams

  4. create separate processes

Question 10 Python generator is

  1. yield instruction
  2. function in which there is a yield statement
  3. special call yield from
  4. object of type concurrent.futures.Future

Question 11 Mark all true statements:

  1. the generator stores the value to generate the next sequence element in local variables
  2. exception StopIteration is used to stop the iterator
  3. the iterator stores the value to generate the next sequence element in self
  4. the iterator interrupts its execution at each iteration, preserving the state of local variables

     Question 12 Mark all true statements:

  5. exceptions cannot be handled in coroutines; this should be done in the main thread

  6. from one coroutine, you can call another with yield from
  7. coroutines are executed in separate threads in parallel
  8. The coroutine can interrupt its work, preserving its state and the values ​​of all local variables

Question 13 Mark all true statements regarding the asyncio event loop:

  1. allows you to perform callable functions and python objects
  2. performs all the corutines in sequence, switching the context between them
  3. responsible for memory allocation in the main process
  4. allows you to perform korutiny registered in it
  5. performs several corutin in parallel in different threads
  6. switch context between python threads

     Question 14 Mark all true statements:

  7. an object of type asyncio.Task stores the associated coruntine and contains the status of its execution

  8. the blocking code in Python will not affect the execution of other korutin in the asyncio event loop
  9. You can create chains from objects of the asyncio.Future type and wait for them to run in the asyncio event loop
  10. an object of type asyncio.Task is executed in a separate control flow, without affecting the execution of other objects of type asyncio.Task

Aucun commentaire:

Enregistrer un commentaire