Skip to content

[Introduction] Wrong output presented for __doc__attribute of number_to_the_power_of #2833

@ghost

Description

Hi,
I was reading the Introduction article about Python (link) and found a code snippet that I tested in my IDLE Shell (Python 3.8.10).
Markdown permalink:


def number_to_the_power_of(number_one, number_two):
    """Raise a number to an arbitrary power.
    
    :param number_one: int the base number.
    :param number_two: int the power to raise the base number to.
    :return: int - number raised to power of second number
    
    Takes number_one and raises it to the power of number_two, returning the result.
    """

    return number_one ** number_two

And then:
print(number_to_the_power_of.__doc__)

What I get is:

Raise a number to an arbitrary power.
    
    :param number_one: int the base number.
    :param number_two: int the power to raise the base number to.
    :return: int - number raised to power of second number
    
    Takes number_one and raises it to the power of number_two, returning the result.

But in lines 182-184 there is a different output (link):

Returns float or int.
       Takes number_one and raises it to the power of number_two, returning the result.

Is it correct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions