CBSE Class 11: Python Fundamentals 3

Getting Help in Python

You can also get help with regards to a particular command in interactive mode. Just type the help() command on the shell and then hit the enter key. You will see the following:

>>> help()

>>> help()
Welcome to Python 3.7's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics".  Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contains a given string such as "spam", type "modules spam".


Now to find the help for a particular command, a simple type that command, for instance, to find help for the print command, simply type print and hit the enter key. The result will look like this:

help> print
Help on built-in function print in module builtins:

    print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
    Prints the values to a stream, or to sys.stdout by default.
    Optional keyword arguments:
    file:  a file-like object (stream); defaults to the current sys.stdout.
    sep:   string inserted between values, default a space.
    end:   string appended after the last value, default a newline.
    flush: whether to forcibly flush the stream.


To exit help, type q for “quit” and then hit the enter key. You will be taken back to the Python shell.

Pros and Cons of Interactive Mode

The following are the advantages of running your code in an interactive mode:

* Helpful when your script is extremely short and you want immediate results.
* Faster as you only have to type a command and then press the enter key to get the results.
* Good for beginners who need to understand Python basics.

The following are the disadvantages of running your code in the interactive mode:

* Editing the code in interactive mode is hard as you have to move back to the previous commands or else you have to rewrite the whole command again.
* It’s very tedious to run long pieces of code.

Number Of Visitors