Level 9 : What will be the output of the following code?


x = 50
def func(x):
    print('x is', x)
    x = 2
    print('Changed local x to', x)
func(x)
print('x is now', x)

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