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