Write a program to print some Python built-in functions documents, such as abs(), int(), raw_input()

  • Python has many built-in functions, and if you do not know how to use it, you can read documents online or find some books. But Python has a built-in document function for every built-in function.
  • Please write a program to print some Python built-in functions documents, such as abs(), int(), raw_input().
  • And add a document for your own function.

Hints:

  • The built-in document method is doc

Solution:

print abs.__doc__
print int.__doc__
print raw_input.__doc__

def square(num):
    '''Return the square value of the input number.
    
    The input number must be integer.
    '''
    return num ** 2

print square(2)
print square.__doc__
Code language: Python (python)

Leave a Comment