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