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


A = [[1, 2, 3],
     [4, 5, 6],
     [7, 8, 9]]
[A[i][i] for i in range(len(A))]

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