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