Created
January 31, 2022 23:26
-
-
Save ycui1/2259f6a25fe6726f1c09aaf5d8e2bd71 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quotient(dividend, divisor, taking_int=False): | |
""" | |
Calculate the product of two numbers with a base factor. | |
:param dividend: int | float, the dividend in the division | |
:param divisor: int | float, the divisor in the division | |
:param taking_int: bool, whether only taking the integer part of the quotient; | |
default: False, which calculates the precise quotient of the two numbers | |
:return: float | int, the quotient of the dividend and divisor | |
:raises: ZeroDivisionError, when the divisor is 0 | |
""" | |
if divisor == 0: | |
raise ZeroDivisionError("division by zero") | |
result = dividend / divisor | |
if taking_int: | |
result = int(result) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment