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