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