
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How do we use Python in interactive mode?
Python is a high level programming language that helps a user to run a program and integrate systems more efficiently; as it executes a program in comparatively fewer lines of code. In this programming language, a code can be run in two ways −
Interactive mode, and
Script mode
Note − To run a python code interactively, we use the command prompt in Windows, terminal in Linux and macOS, etc.
In this article, we will learn how to execute a python code in interactive mode in Windows. However, the commands are almost same in other operating systems as well.
Python in Interactive Mode
Running a Python code interactively must be done from the Command Prompt of Windows. This is possible using the python or python3 keywords, depending on the version of Python installed in your system.
Let us look at a step by step process to run a Python code from a Windows Command Prompt.
Example
Execute Python from command prompt to run Python interactive shell.
C:\user>python >>>
Python prompt is made up of three greater than symbols. Any valid expression can now be evaluated interactively. Let us start with evaluating arithmetic expression.
>>> 2+3*5 17
You can assign value to a variable or accept input from user, and print its value.
>>> name=input("enter your name") enter your name TutorialsPoint >>> name ' TutorialsPoint'
Note − Various applications like Jupyter Notebook can also allow you to run your Python code interactively.
- Related Articles
- How do we use Python in interactive mode?
- How do we use Python in script mode?
- How do we use double quotation in Python?
- Why do we use random.seed() in Python?
- Why do we use pandas in python?
- How do we use re.finditer() method in Python regular expression?
- How do we use equivalence (“equality”) operator in Python classes?
- How do we use easy_install to install Python modules?
- How do we use Python Regular Expression named groups?
- How to get the MySQL interactive output format in batch mode also?
- How do we use runOnUiThread in Android?
- How do we use file.readlines() to read multiple lines using Python?
- How do we use a delimiter to split string in Python regular expression?
- Why do we use re.compile() method in Python regular expression?
- When do we use crosstab and pivot_table in Python Pandas?
- How do we use # in jQuery Attribute Selector?
