Tuesday 21 July 2015

Hello world in python !

As we have discussed, Python is the language of choice for hackers and security analysts for creating powerful and effective tools.it is most used language for exploit writing.In Programming :  Ethical Hacker way blog you'll find complete tutorials for learning python in hacker way.So let's start.

There is a tradition that whenever you learn a new programming language, the first program that you write and run is the 'Hello World' program. So before we start complex program, we will start with simple "Hello world" program.

Using the python interpreter prompt :
C:\Users\Root>python
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print 'Hello World'
Hello World
>>>
                         
                                     
       
We use print to  print any value that you supply to it. Here, we are supplying the text Hello World and this is promptly printed to the screen.

Using a Source File(Kali-Linux) :
#!/usr/bin/python
#Filename : helloworld.py
print 'Hello World'
Run this program by opening a shell (DOS prompt for windows user) and entering the command :
python helloworld.py

Executable Python programs :
This applies only to Linux/Unix users but Windows users use py2exe to make it Executable. First, we have to give the program executable permission using the chmod command then run the source program.
$ chmod a+x helloworld.py
$./helloworld.py
Hello World

If you like this post or have any question, please feel free to comment!

No comments:

Post a Comment

Blogger Widget