Level 1 : Infinite arithmetic sequence.


def arithmetic_seq(start, step):
    while True:
        yield start
        start += step

gen = arithmetic_seq(1, 3)
for _ in range(5):
    print(next(gen), end=" ")

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