Середній рівень Python для розробників
Jasmin Ludolf
Senior Data Science Content Developer
Рядок (блок тексту), що описує функцію
Допомагає зрозуміти, як користуватися функцією
Help on built-in function round in module builtins: round(number, ndigits=None)Round a number to a given precision in decimal digits. The return value is an integer if ndigits is omitted or None. Otherwise the return value has the same type as the number. ndigits may be negative.
# Отримати інформацію, зокрема рядок документації
print(help(round))
Help on built-in function round in module builtins:
round(number, ndigits=None)
Round a number to a given precision in decimal digits.
The return value is an integer if ndigits is omitted or None. Otherwise
the return value has the same type as the number. ndigits may be negative.
None
# Отримати лише рядок документації
print(round
# Отримати лише рядок документації
print(round.
# Отримати лише рядок документації
print(round.__
# Отримати лише рядок документації
print(round.__doc
# Отримати лише рядок документації
print(round.__doc__)
Round a number to a given precision in decimal digits.
The return value is an integer if ndigits is omitted or None. Otherwise
the return value has the same type as the number. ndigits may be negative.
$$
$$
.__doc__: атрибут «dunder-doc»def average(values):# Однорядковий docstring """Знайдіть середнє послідовності значень і округліть до двох знаків після коми."""average_value = sum(values) / len(values) rounded_average = round(average_value, 2) return rounded_average
# Отримати наш рядок документації
print(average.__doc__)
Find the mean in a sequence of values and round to two decimal places.
# Оновити рядок документації функції average.__doc__ = "Calculate the mean of values in a data structure, rounding the results to 2 digits."print(help(average))
Help on function average in module __main__:
average(values)
Calculate the mean of values in a data structure, rounding the results to 2 digits.
def average(values): """ Знайдіть середнє послідовності значень і округліть до двох знаків після коми. """average_value = sum(values) / len(values) rounded_average = round(average_value, 2) return rounded_average
def average(values): """ Знайдіть середнє послідовності значень і округліть до двох знаків після коми. Args: """average_value = sum(values) / len(values) rounded_average = round(average_value, 2) return rounded_average
def average(values): """ Знайдіть середнє послідовності значень і округліть до двох знаків після коми. Args: values (list): Список числових значень. """average_value = sum(values) / len(values) rounded_average = round(average_value, 2) return rounded_average
def average(values): """ Знайдіть середнє послідовності значень і округліть до двох знаків після коми. Args: values (list): Список числових значень. Returns: rounded_average (float): Середнє значення, округлене до двох знаків після коми. """average_value = sum(values) / len(values) rounded_average = round(average_value, 2) return rounded_average
# Довідка
print(help(average))
Help on function average in module __main__:
average(values)
Find the mean in a sequence of values and round to two decimal places.
Args:
values (list): A list of numeric values.
Returns:
rounded_average (float): The mean of values, rounded to two decimal places.
Середній рівень Python для розробників