Level 10 : What will be the output of the following Python code?


>>> a=(0,1,2,3,4)
>>> b=slice(0,2)
>>> a[b]

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