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