Level 1 : What happens here?


import asyncio

async def main():
    print("A")
    await asyncio.sleep(0)
    print("B")

asyncio.run(main())

Author: VenuEmmela | Tags: async | 1859+ Python FAQs | Share
thread | difference-between-threads-and-processes | built-in | boolean-and-non-boolean | asyncio-module | built-in-modules | class-decorators | center | attribute | assert | decorator | collection | datatype | data-structure | command-line-parsing | python-history | complex-number | list-mutation | built-in-function | magic-method | dictionary | data-type | mysql | mathematics | comment | list-comprehension | call | logical-operator | access-modifier | data-structures | counter | multiprocessing | logical-operator | debugging | decimal | mathematical-function | control-flow | class-and-inheritance | conditional-statement | list-vs-tuple | syntax-error | assignment-operator | math-copysign | list-operation | recurssion | dictionary-comprehensions | memory | conversion | membership-operators-(in,-not-in) | keyword | booleans | comprehension | loop | binary | for | directory-operations | destructor | handling-missing-values-(fillna,-dropna) | sum-function | descriptors | operator-or | module | round | sum() | application | package-management | range | built-in-function | arithmetic-operation | classes | conditional-statement | single-inheritance | __all__-attribute | regex | formatting-with-strftime | asyncio | bitwise-operator | namespace | function | design-principle | loop-control-statements | docstring | string-method | sets | string-manipulation | lambda | __future__ | name-mangling | multiple-except-blocks | feature | print | boolean | syntax | bitwise-operator | __init_subclass__ | syntax-error | creating-and-starting-threads | rollback | identifier | filtering-and-indexing | comparison | functions | data-types | literal-characters-and-special-characters | immutability | append | logical-operators | init | input | operations | string | dicts | namedtuple | swapping | global-variable | logical-operation | dictionary-methods | invalid-list | else | encoding | string-formatting | nested-loop | list | math | choice | multiple-inheritance | software-design | format | indexing | method | immutable-data-type | recursion | dictionaries | complex | iterators | type-conversion-and-casting | type_conversion | threading | max-min | array | pseudocode | scientific-notation | statement | input-function | type-conversion | dataframe-and-series-objects | condition | objects | numeric | copy | constructor | memory-management | global | class-and-object | using-join()-and-is_alive()-methods | sys-module | global-variable | list-join | sys | virtual-environment | multiple-inheritance | loops | else-statement | loop-control | encapsulation | pass | creating-custom-modules | using-else-and-finally | methods | default-mutable-argument | assignment-operators | multithreading | class | working-with-dates-and-times | data-structures-in-python | functional-programming | matrix-list-comprehension | update | data-structure | tuple | list-slicing | inherit | zip | static-method | precedence-and-associativity | python | tuple-methods | pickling--unpickling | lists | data-type-conversions | collections | list-comprehensions | head-and-tail | higher-order-function | datetime | parameter | tuple-unpacking | fabs-function | sorting-and-ranking | string-iteration | strings | introduction-to-python | compute | library | generators-in-python | functional-programming | yield | return-statement | identity-operator | stack | mapping-function | exponentiation | time-series-with-pandas | while-else-loop | arbitrary-arguments-(*args,-**kwargs) | object-attribute | joining-and-merging-dataframes | method-overloading | introduction-to-threads | virtual-environment | string-formatting | touples | control-flow | while-and-for-loop | list,-set,-and-dictionary-comprehensions | filter-function | gil | advanced-file-operations | list-methods-and-slicing | with-statement | benefit | deep-copy | managing-directories-with-os-and-shutil | sorting | regular-expression | function-argument | file | context-manager | quantifiers-(*,-+,-?,-{}) | async | generator | writing:-write(),-writelines() | parsing-with-strptime | binary-operation | match | anchors-(^,-$) | string-method | opening-files-(open()) | string-slicing | list-comprehension | frozenset | python-django | inheritance | aggregating-data-with-functools.reduce() | map-function | conditional-statements | reading-and-writing-large-files-efficiently | iterable | floating-point-precision | string-concatenation | random-function | data-type | python-operators | interpreter | syntaxerror | arithmetic-expression | version-check | counter-function | list-method | boolean-masking | tuples | min-max-function | working-with-file-paths | shallow-copy | file-handling | bitwise | using-lists-as-stacks | print-statement | defining-functions | set | control-statement | oops | using-assertions-(assertequal,-assertraises) | slice | while-loops | datetime.date,-datetime.time,-datetime.datetime | overflow | reading-and-writing-files | oop | why-use-multiprocessing-over-threading?-(gil) | data_structure | def | typeerror | using-map()-for-transformations | python-syntax-and-structure | exception-handling | iterator | matplotlib | class-and-instance-variable | basic | exception | numpy | goto-function | error-handling | string-methods | slicing | odd-number | random | set-operation | lambda-function | error-handling | intering | generators | postfix | heap-memory | enumerate() | raise-statement | key-value-pairs | working-with-binary-files-(rb,-wb) | int | min-function | escape-operator | reading:-read(),-readline(),-readlines() | operand | expression | indentation | round-function | matrix | mutable | operators | precedence | staticmethod | using-the-threading-module | unit-testing | operator | version | id-function | global-keyword | file-handling | floats | operator-and | function-and-scope | test-discovery | zip-function | exception-handling | while-loop | variable | operator-overloading | polymorphism | python-repl | file_handling | error | identity-operators-(is,-is-not) | thread-synchronization | turtle | expand-tab | python-module | input-function | factorial-function | filter | integer | indexing:-loc-vs-iloc | overriding-methods | integers | pandas | sorted | raise | introduction-to-multiprocessing | python_version | identity-operator | using-yield-in-functions | regular-expressions | using-os-and-pathlib-modules | lambda-functions | thread-safe-data-structures-(queue.queue) | pep | walking-through-directories-using-os.walk() | type-conversion | zfill-function | lambdas | installation | list-indexing | working-with-temporary-files-using-tempfile | import-method | implementation | split | join | formal-and-actual-parameter | default-arguments | string-slicing ...