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