Level 1 : What will be the output of the following Python code?


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

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