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