Level 10 : 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 | 1736+ Python FAQs | Share
input-function | asyncio-module | call | built-in | math | operator-overloading | matrix-list-comprehension | encapsulation | list-method | arithmetic-expression | file | virtual-environment | bitwise-operator | control-statement | mathematical-function | pickling-&-unpickling | syntax-error | collections | assert | method | virtual-environment | random | goto-function | async | syntaxerror | asyncio | python-repl | identifier | indentation | logical-operator | datatype | binary-operation | function-argument | loop-control | classes | deep-copy | data_structure | nested-loop | filter-function | generators-in-python | software-design | design-principle | multiprocessing | while-and-for-loop | stack | encoding | global | lists | split | turtle | class-and-instance-variable | sorting | exception-handling | attribute | exception | logical-operator | inheritance | implementation | feature | operators | higher-order-function | heap-memory | __future__ | assignment-operator | list-comprehension | access-modifier | class-and-inheritance | object-attribute | installation | round | odd-number | keyword | factorial-function | python_version | class-and-object | zfill-function | methods | shallow-copy | name-mangling | syntax-error | pep | sorted | precedence-and-associativity | function-and-scope | debugging | choice | data-structure | yield | file_handling | oops | multiple-inheritance | version | mysql | function | magic-method | command-line-parsing | multithreading | input | list-mutation | iterable | list-comprehension | join | expand-tab | round-function | python-django | boolean-and-non-boolean | tuple | package-management | min-max-function | enumerate() | threading | list-join | gil | bitwise-operator | immutable-data-type | string-manipulation | statement | string-slicing | return-statement | lambdas | id-function | random-function | __all__-attribute | set | memory-management | print-statement | data-structure | input-function | while-else-loop | string-formatting | parameter | memory | error-handling | generator | operator-and | touples | namedtuple | append | map-function | sys-module | operator-or | string-iteration | decorator | conditional-statement | identity-operator | logical-operation | python-history | decimal | conditional-statement | staticmethod | indexing | fabs-function | list-operation | sum() | slicing | thread | for | operations | formal-and-actual-parameter | identity-operator | oop | copy | version-check | def | string-slicing | python-module | matrix | file-handling | recurssion | comment | scientific-notation | match | while-loop | destructor | functions | string-formatting | regex | collection | list | overflow | application | precedence | condition | import-method | immutability | init | invalid-list | typeerror | global-variable | center | tuple-unpacking | conversion | zip | built-in-function | arithmetic-operation | numpy | comprehension | complex | math-copysign | sum-function | docstring | max-min | file-handling | counter-function | namespace | interpreter | __init_subclass__ | benefit | python | update | class | data-type | format | functional-programming | frozenset | exponentiation | comparison | default-mutable-argument | dicts | global-keyword | operator | basic | context-manager | expression | range | counter | print | floating-point-precision | zip-function | swapping | loop | syntax | string-concatenation | integer | set-operation | constructor | slice | complex-number | recursion | dictionary | built-in-function | variable | string-method | data-structures | filter | mathematics | pandas | rollback | raise | postfix | escape-operator | exception-handling | else-statement | type_conversion | min-function | library | list-slicing | mapping-function | type-conversion | operand | lambda-function | bitwise | lambda | module | iterator | list-indexing | regular-expression | control-flow | data-type | inherit | static-method | generators | control-flow | list-vs-tuple | type-conversion | with-statement | array | mutable | error | sys | numeric | string | dictionaries | descriptors | head-and-tail | compute | polymorphism | loops | matplotlib | objects | binary | datetime | string-method | pseudocode | boolean | global-variable | int ...