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