Level 10 : what is the following output code?


def foo(fname, val):
    print(fname(val))
foo(max, [1, 2, 3])
foo(min, [1, 2, 3])

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