Level 1 : What is the output of the following code?


def sample():
   try:
        return 6
   finally:
        return 5
k = sample()
print(k)

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