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