Level 1 : What will be printed?


class A:
    x = 10

a1 = A()
a2 = A()
A.x = 20
a1.x = 30
print(A.x, a1.x, a2.x)

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