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 | 1736+ Python FAQs | Share
arithmetic-operation | immutable-data-type | odd-number | for | bitwise | exception-handling | map-function | gil | collections | list-vs-tuple | floating-point-precision | comparison | class | loop-control | formal-and-actual-parameter | feature | frozenset | type-conversion | postfix | lists | deep-copy | python | context-manager | sorting | string-method | memory-management | filter | assert | goto-function | precedence-and-associativity | matrix | call | random-function | encoding | data-structure | print-statement | while-else-loop | exponentiation | oop | min-function | mapping-function | counter-function | objects | tuple | center | polymorphism | class-and-instance-variable | list-join | list-method | escape-operator | attribute | parameter | touples | functions | syntax-error | built-in | debugging | numpy | expression | binary-operation | operators | else-statement | namedtuple | list-indexing | sum() | __all__-attribute | global-variable | generator | id-function | string-method | multithreading | async | keyword | input | mysql | condition | set-operation | iterable | statement | default-mutable-argument | error | sys | command-line-parsing | object-attribute | loops | __init_subclass__ | type_conversion | return-statement | virtual-environment | string-iteration | function | string-formatting | join | stack | version | typeerror | pseudocode | boolean-and-non-boolean | asyncio | file_handling | version-check | list-mutation | python-repl | logical-operation | implementation | memory | encapsulation | operator-or | copy | turtle | integer | recursion | exception | magic-method | list-comprehension | complex | regular-expression | numeric | with-statement | scientific-notation | rollback | data-structure | list-comprehension | string-formatting | file | namespace | global-variable | random | logical-operator | benefit | list | collection | matplotlib | mutable | choice | library | enumerate() | inheritance | round | conversion | name-mangling | heap-memory | string-slicing | data_structure | sum-function | installation | overflow | slicing | error-handling | function-argument | loop | invalid-list | print | filter-function | range | pandas | higher-order-function | int | immutability | access-modifier | import-method | raise | decorator | static-method | bitwise-operator | multiprocessing | multiple-inheritance | factorial-function | comprehension | basic | swapping | min-max-function | destructor | counter | functional-programming | data-type | boolean | interpreter | exception-handling | match | control-flow | zip-function | classes | nested-loop | application | string-manipulation | operator-overloading | python_version | max-min | control-flow | operator-and | while-loop | syntax | mathematical-function | descriptors | lambdas | operand | variable | datetime | slice | yield | def | zip | sorted | math | class-and-inheritance | asyncio-module | method | format | set | global-keyword | mathematics | package-management | methods | matrix-list-comprehension | python-module | complex-number | file-handling | identity-operator | compute | function-and-scope | global | constructor | threading | design-principle | identity-operator | built-in-function | while-and-for-loop | input-function | control-statement | update | __future__ | python-history | operator | arithmetic-expression | oops | expand-tab | pep | binary | staticmethod | dictionaries | type-conversion | datatype | data-structures | thread | iterator | syntax-error | software-design | docstring | conditional-statement | init | logical-operator | indexing | shallow-copy | string | python-django | sys-module | regex | fabs-function | assignment-operator | append | lambda-function | generators | module | comment | dicts | string-concatenation | data-type | virtual-environment | indentation | pickling-&-unpickling | split | list-operation | input-function | class-and-object | recurssion | dictionary | zfill-function | operations | built-in-function | string-slicing | conditional-statement | math-copysign | list-slicing | identifier | syntaxerror | inherit | lambda | round-function | array | decimal | tuple-unpacking | precedence | generators-in-python | bitwise-operator | file-handling | head-and-tail ...