Remember
help() displays documentation. It is for learning about an object, rather than executing that object’s normal behavior.
help() displays documentation. It is for learning about an object, rather than executing that object’s normal behavior.
Follow the example, change its sample, and compare what happens.
Explain the result and test your understanding.
Focus on how the names, objects, and calculations change. We’ll inspect the printed output in the next section.
Follow the code and watch its state change. Guided simulation.
def greet():
"""Print a greeting."""
print('hello')
help(greet)Top-level scope
function greethelp() displays documentation. It is for learning about an object, rather than executing that object’s normal behavior.
(no output)
What do you expect this program to print?
EXAMPLE INSTRUCTIONS
def greet():
"""Print a greeting."""
print('hello')
help(greet)
|
v
DISPLAYED RESULT
Help on function greet in module __main__:
greet()
Print a greeting.
FINAL BINDINGS
greet --> object 1 (function)
object 1: function greetChoose a different sample input, then follow every step through to the output. Before revealing it, predict what the program will display.
Choose a sample and follow its execution. Guided simulation.
def greet():
"""Print a greeting."""
print('hello')
help(greet)Top-level scope
function greetThe example has finished. Compare the final output with the values and references above.
Help on function greet in module __main__:
greet()
Print a greeting.
What do you expect this program to print?
def greet():
"""Print a greeting."""
print('hello')
help(greet)help() FunctionThe help() function in Python is a built-in tool that gives you quick access to documentation about Python objects — such as functions, classes, modules, and keywords.
This is a very useful function for beginners who want to understand what a function or module does without searching online.
help(object)
or, simply:
help()
object – Optional. Can be a function, class, module, keyword, or anything Python can describe.help(len)
Help on built-in function len in module builtins:
len(obj, /)
Return the number of items in a container.
import math
help(math)
Help on module math:
NAME
math - This module provides access to the mathematical functions...
FUNCTIONS
acos(...)
acosh(...)
...
help()
This opens an interactive help utility in the terminal. You can type topics like modules, keywords, symbols, or topics.
To exit, press q or use quit.
help("len") will work but gives help on the string, not the function.len, not "len").If you’re in an environment without internet (like a coding test), help() can give you quick guidance on syntax and usage.
help() displays documentation for Python objects.Try using help() on the following Python objects:
strlistabsdictExample:
help(str)
Connect what you noticed in the example with the idea below.
help() displays documentation. It is for learning about an object, rather than executing that object’s normal behavior.
help() calls every function it documents.
This is the misconception to avoid.Reference checks are optional and do not count toward course progress.