Level 1 : What is the output?


def fibonacci(n):
    a, b = 0, 1
    for _ in range(n):
        yield a
        a, b = b, a + b

g = fibonacci(5)
print(list(g))

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