Basics: Interactive Interpreter
Basics: Interactive Interpreter
ExerciseI Basics
instructiongin
a) Running Interactive interpreter and a Python Seript
1.UsingInteractive Prompt:-
interactive mode would be started
It is the simplest way to run the python programs. This of the
console and with IDE(Integrated Development Environment). The drawback
with DOS
save a file.
interactive mode is it doesn't allow your program to
X
3.9.5
eIDLEShell
Window Helo
Cile Edit Shell Debug Options 64 bit (A ^
May 3 2021, 17:27:52) [MSC v.1928
erthon 3.9.5 (tags/v3.9.5:0a7dcbd,
win32
D64) ) Tn for more information.
Tsme nhelp", "copyright", "creditg" or "licenge () n
Lab)
nt ("Helld, Welcome to Python
Python Lab
tello, Weicome to
Environment:
2, Using the Integrated Development
Interface(GUI) environment as well .It
We can run python from Graphical User
Debug etc.
provides lot of menu's like File, Edit, Shell,
Pr0yems/Pythc/Pthon3913.py(3.9.5;
Vsets'del:-gpDeld Lersi
Options Window Help
Edit Format Run
X=10
y=20
Ln: 4 Col: 34
Sum of twO
RESTART: C:/0sers/dell/AppData/Local/ Programs / Python/Python39/la.py
nwmbers is 30
Ln: 6 Col: 4
3. Invoking the Python Interpreter From Command
Prompt:
We can invoke from the DOS conmand
prompt
º To use this way of execution we have to set the path as
follows.
Click on start
Right click on ny computer and select properties.
Separate window will be open and click on advanced system settings in it.
System properties window will be open here click on environment variables button.
Go to the system variable window and select the path variable button
º Put(;) at the end for the variable value and type (C:\python 27) and
click OK and closed all
windows
Open the DOS command prompt and go to the directory where you have saved your files
Type "python file_name.py" and press enter
lf everything goes well, you will see results being displayed in the python shell
prompt (or)
you willsee errors otherwise
b) Write a program to purposefully raise Indentation Error and correct it
Source code :
Error Code Error Corrected Code
irTrue: if True:
prn("True") print("True")
clse: clse:
prin("False") print("False")
Output:
True
ir True: if True:
prin("True l") prn("Truel")
Pim"Truc2")
print("Truc")
else:
clse:
prin("False")
prin("False")
Output:
Truel
True2