Level 1 : What will be the output of the below python code?


def truncate(n, decimals=0):
    multiplier = 10 ** decimals
    return int(n * multiplier) / multiplier

truncate(1.625, 2)

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