Sunday, August 31, 2014

Python Tutorial 1 - Hello World!



 
mamesblog7.blogspot.com
Hello , welcome to Mohammed’s Python Tutorial series. The reason I chose Python programming language  to do this tutorial is because Python is a very easy language to learn. If you are new to programming , you just came to the right place place. In this first tutorial, I’ll be going on how to do the basic and simple “Hello World “ Program. If you have a Python 3 or a newer version of Python installed ,then lets start along. First open the Python IDLE (and by the way IDLE  stands for Interactive Development Environment) . It will look like this.
Interactive shell /IDE/
And then click on the  File >> New window  to start a new project (Or just press Ctrl + N).This will open a new black space to do the actual coding.You can type in the code in the Python shell but this will be more organized and will help you understand the code better.
Blank Project
And then type in the following piece of code.
Source code
Small and simple as you can see. When you run this you will be asked to save it.  You will give it a name. I named mine ‘hello world’. Any python file is saved with a .py or .pyw extension.You just type in the name and python will add .py for you.
And when you run this >>
Output
Yaay, you just made a very simple program that outputs Hello World! Yeah , what a start , everything is working perfect! The only code we wrote is –
#My first program
print("Hello World!!")
 Now lets go through the code. The first line is a comment. It have no effect on the program. It is useful when you write long lines of code to kind of document what you are coding. Anything written next to a hashtag (#) will be treated as a comment. But the next line is a piece of code which will print Hello World. The print()  function will print whatever you write in the parameters. You just have to make sure you write the string of text in a parentheses (“ ”).
So that was all for today ,, it will be a long and fun journey. We will learn how to do some very awesome programs in Python.  You can keep up with me in this blog or if you get this in somewhere else my blog is @ www.mamesblog7.blogspot.com  , don’t forget to leave a comment and put it on your RSS Feed because I’ll be posting more and more Python tutorials. 
Goodbye