Interactive Mode Programming
Using the interpreter without passing a script file as a parameter known as interactive mode programming. To start interactive mode start command prompt and type "python" without any arguments. Then you can see >>> symbol is indicating in command prompt. Interactive mode is useful for test a code instantly without saving it. For example 5*5 in python interactive mode will give response as 10 immediately. This a good feature for beginners to understand python syntax.
Example: IDLE (Integrated Development Environment) is an integrated development environment for Python.
First Python Program
Writing Your First Python Program
Create a folder called Python Programs on your C:/drive.
In Notepad type the following program exactly as written:
print "Hello World!"
Go to File and click on Save as.
In the field Save in browse for the C: drive and then select the folder Python Programs.
For the field File name type Hello.py.
In the field Save as type select All Files
Click on Save. You have just created your first Python program.
Running Your First Program
Go to Start and click on Run.
Type cmd in the Open field and click OK.
A Command Prompt will appear. Type cd C:/and hit the key Enter.
Type cd Python Programs and hit Enter. It should take you to the Python Programs folder.
To run the program, type python Hello.py and hit Enter.
You should see the Following output.
No comments:
Post a Comment