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