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