Python Interactive Mode
Python Interactive Mode
Python allows the user to work in an interactive mode . It is a way of using the Python interpreter by executing Python commands from the command line with no script.
This allows the user to type an expression, and immediately the expression is executed and the result is printed.
To start an interactive mode. we will see that the Python command line window appears as shown in Fig.1
Python 3.6 (32-bit)
Python 3.6.0 <v3.6.0:41df79263all, Dec 23 2016, 07:18:10> [MSC v. 1900 32 bit <Intel>] on win32
Type "help", "copyright" , "credits" or "license" for more information.>>>-
Python Interactive Window
The ">>>" is the prompt used in the Python interactive mode which indicated that the prompt is waiting for the Python command and produces the output immediately.
Example:
>>>5+7
12
>>>print("Hello world |")
Hello world |
>>>num=10
>>>num=num/2
>>>print(num)
5.0
Working in the interactive mode is convenient for testing a single line code for instant execution. But in the interactive mode, we cannot save the statements for future use and we have to retype the statements to run them again .
Comments
Post a Comment