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