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