Level 1 : What will be the output of the following code?


f =lambda x:bool(x%2)
print(f(20), f(21))

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