KwickAcademy Course Topics · 5 min · free
Interactive mode vs script mode
Learn the two ways to run Python: interactive mode (the >>> shell) and script mode (a saved .py file), and when to use each. In interactive mode you type one line and get the answer at once; in script mode you write many lines in a file and run it all.
Follows the syllabus of: CBSE Class 11 Computer Science (083)
On screen in this lesson
Two ways to talk to Python
| Interpreter: the program that runs your Python code |
| Interactive mode: type one line, get the answer at once |
| Script mode: write many lines in a file, then run it all |
| A script file is saved with the .py ending |
Where you find interactive mode
| Open IDLE: the Shell window shows >>> |
| Or type python (python3 on Mac) in a terminal or command prompt |
| Type exit() to leave the shell |
Side by side
| Point | Interactive | Script |
|---|---|---|
| Runs | one line at once | whole file |
| Saved? | no, lost on close | yes, a .py file |
| Shows values | on its own | only with print |
| Best for | quick tests | real programs |
| Edit and rerun | retype lines | edit, run again |
Errors in each mode
| Shell: the error shows, and >>> comes back at once |
| Script, NameError: lines above it have already run |
| Script, SyntaxError: nothing runs at all |
| The message names the line number and the error |
Quick recap
| Interactive mode: >>> prompt, one line, instant answer |
| Script mode: a saved .py file, run all at once |
| The shell echoes values; a script needs print() |
| Test small ideas in the shell, build programs as scripts |
Quick answers
Why does a value show in the shell but not in a script?
The shell echoes values on its own. A script shows a value only when you use print().
When should I use each mode?
Use the shell to test small ideas, and script mode to build real programs you can save.
KwickClips from this lesson
Short clips, one idea each. Good for revision the night before.
The full lesson, in text
Hello students, welcome to Kwickprep. You type fifteen plus ten in Python and see twenty five. You save the same line in a file, run it, and see nothing. Why? Today we will learn the two ways to run Python, interactive mode and script mode, and when to use each.
First, some new words. The interpreter is the program that reads your Python code and runs it. In interactive mode, you type one line, press Enter, and the interpreter answers at once. In script mode, you write many lines in a file first, and then run the whole file together. That file is called a script, and its name ends in dot pie, like bill dot pie.
When you open the Python shell, you see three arrow marks. This is called the prompt, and it means Python is waiting for you. Type fifteen plus ten and press Enter. Python shows twenty five straight away, with no print needed. Now store Surat in a variable called city. Type just city, and Python shows its value, with quotes around it.
There are two easy ways to reach this prompt. Open IDLE, the editor that comes with Python, and its Shell window shows the prompt. Or open a terminal or command prompt and type python, or python three on a Mac. When you are done, type exit with round brackets to leave.
Now script mode. In IDLE, click File, then New File, and type these four lines. Save the file as bill dot pie. Press the F five key, or choose Run Module. Python runs every line from top to bottom. The print function shows the text Canteen bill, and then twenty five.
Here is the trap from the start of the lesson. Echo means Python shows a value on its own, without print. The shell echoes values, but a script does not. Pause and predict. How many times does twenty five appear when this runs as a script? Only once. The line with just bill does nothing in a script, so only print shows the answer.
Let us compare the two modes side by side. Interactive mode runs one line at a time, while script mode runs the whole file. Interactive work is lost when you close the shell, but a script stays saved. The shell shows values on its own, but a script shows them only with print. Interactive mode is best for quick tests, and script mode is for real programs. To fix a mistake in the shell you retype lines, but in a script you edit and simply run again.
Programmers use both modes together. Suppose you forget what division gives in Python. Test it in the shell before writing your program. One slash is normal division, so seven divided by two gives three point five. Two slashes is floor division, which keeps only the whole number part, so we get three. The percent sign is the modulus operator, which gives the remainder, so we get one.
Now that you know the answers, write the real program as a script. Seven students sit two to a bench. Floor division gives the number of full benches, which is three. Modulus gives the students left over, which is one. The file is saved, so you can change seven to forty tomorrow and run it again.
Mistakes behave a little differently in each mode. In the shell, you see the error, and the prompt comes back so you can try again. In a script, a name error stops Python at that line, but the lines above it have already run and printed. A syntax error, like a missing bracket, is caught before the script starts, so not even the first line runs. The message tells you the line number and the error name.
Let us revise what we learned today. Interactive mode shows a prompt and answers each line at once. Script mode runs a saved dot pie file from top to bottom. The shell shows values on its own, but a script needs print. So test small ideas in the shell, and build your real programs as scripts.
Courses that teach this
| Course | Unit |
|---|---|
| Programming All levels Python | Getting Started with Python |
Voice-over in this lesson is AI-generated. The script is written and checked by Kajal Ma'am. Boards can revise a syllabus mid-year, so confirm anything you plan around against the official board circular. Keep your passwords, OTPs and ID numbers to yourself — we never ask for them. To reach Kajal Ma'am, use the WhatsApp button; sharing your number there is how we call you back.
Free to watch, no sign-up. Live classes with Kajal Ma'am are the paid course; these lessons stay free either way.


