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