Hello World Python:
In this tutorial we are going to use the traditional "Hello, World!" program. And the purpose of "Hello, World!" is not an exercise to find the simplest form of code in a particular language, or anything like that. Its actually to learn about the development environment, and this is what we called development cycle (it takes to edit, and to test, and to change, and to test and to run code in a particular environment). And so for this purpose we use the simplest form of a program itself, so that can get out of the way and then we can focus on the environment.
In this case, I have this up here on the screen in Eclipse. And this is Eclipse using Pydev, which is a Python development environment that runs inside of Eclipse.
Eclipse is an integrated development environment originally written for developing in Java, but it has plug- ins for a lot of different languages. And Pydev is actually a pretty good plug-in for the Python language. And so, we will be using this throughout this course.You do not have to use Eclipse, and if you have some other development environment that you prefer, or you just want to use an editor and a command line, that's perfectly fine. In the above screen shot I have created a python project named "Tutorial" and in that project I have created a ".py" file named "HelloWold.py".
Now its time to write our first program. In the Eclipse editor write the below code to print your first program.
print("Hello, Wrold!")
In Eclipse, if I want to run this Hello, World!, I simply click on this Run button up here, and it will ask me, How I want to run it? and I am going to select Python Run. I only need to do this the first time I run a script.So I am going to say OK.
And here we have the result down here: "Hello, World!"
For writing python programs you can also use python IDLE (shell). To open python IDLE follow these steps:
- Press "window" button.
- write "idle" on search bar.
- Click on "IDLE (python_version)"
4. You will see the following screen and this is the python "IDLE"shell.
5. Now we in the python shell write "print("Hello, World!")" and press enter, you will see your desired output.
This is the end of our first lesson, today you learned about Python and Eclipse development environment and how to write program in python. In my next post you will learn python variable, loops, function etc.....
1 Comments
You made it very easy to learn. Nice sharing
ReplyDelete