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


def sample():
       try:
          print(4)
       finally:
           print(7)
sample()

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