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