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