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