Wednesday, July 2, 2014

Python Programming

Introduction to Python Programming Part 1


What is Python ?

I will not bore you with Big Definition about what is Python. For Go to Google Search Results for: What is Python Programming

But in Short, I tell you, its multi short ways to do multi task and bring your life eazy, sweet and best hack day. You become more lazy day by day when you know PYTHON 

What Thing I should know Already ?

Frankly, You don't need to know anything. But if you know any other language earlier, python will become easy coke. But if you don't know anything earlier than i will tell you form scratch to Advance in Easiest style Ever. So get love with it.

Using Python

We Learn here python3.3 [Latest Edition of Python]

1. Download python from python website Google Search Results for: Download latest Python.
Don't ask me, why i take all to google, and not official website, getting yourself from google is first thing hackers do.. so get hackers style.

2. Installing Python.. It's easy.. like installing any software.. I use Windows 7. But my Tutorial for Windows Users and Linux Users both.

Window User :- Double Click to Installation File to Download.
Linux User :-
Code:
yum install python*
or
apt-get install python*

4. After Installation, Type Below Command :-
Code:
c:\> echo %path%
or for linux user:-
hacker@linux$ echo %PATH%

and you will see your Executable File Program.
Mine is this :-
Code:
D:\oracle\product\10.2.0\db_1\bin;C:\Perl\site\bin;C:\Perl\bin;C:\Python33\;C:\P​rogram Files\Common Files\Microsoft Shared\Windows Live;C:\
rogram Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\PHP\;C:\Windows\system32;C:\Windows;C:\Windows\System3
\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\MySQL\MySQL Server 5.0\
in;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Micro
oft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Nmap

You will have Something Different but output will be few similar.

Using Python Interpreter :-

1. Open CMD [Command Prompt] and Type
Code:
c:\> Python

and python interpreter will start. If python doesnot start reinstall python executables, and if you get any error, Please tell them below, I will help you.

Now, Start Typing First line :-
Code:
>>> print("Hello World")

and you will see "Hello World" is print out, Well I am not teaching you Hello World, these are easy... Now, Not only interpreter or CMD. We will make Python Executable too. so for that, 

1. Open Notepad.
2. Type Below Line, Please note Don't Copy paste. Type it yourself, and than only you will learn.
Code:
#!/usr/bin/python3

print("Hello World")
or, 
Code:
#!/usr/bin/python3

print("I am an Ethical Hacker from World Of Hacker")

Now save file with name "hello.py", please note .py is important as .py is extension for python and different language have their own extensio, similarly python has one extension.

Now, after saving file Open New Command prompt and type below line.
Code:
c:\> python hello.py

And you Will see It will Print Hello World, and all 

Now, Few Important thing Before you Learn More :-

How to print anything in Python ?
We use for now "print()" function of python.

Now, What are things we can print ?
In any Programming Language , there are data divided in different parts.
For Example :-

Number [0,1,2,3,4,5,6,7,8,9] are called integers and in "C" it is represented as "int", and so, on and so forth, in python there is no such thing. .

Just Learn one thing that, there is 2 thing string, integer.

Strings are always written within Quotes [" "]. and integer dont require quotes. Demo :-

In CMD [python cmd]
Code:
>>> print(2)
2
>>> print(12123123)
12123123
[code]

But for Any Character use Double Quote like below :-
[code]
>>> print("This is Character")
This is Character
>>>print("My name is Ethical Hacker")

Now, What are Comments in any programming Language, Comments are Note for Programming Compilers to not Execute these line, it is just for programmers to understand what i wrote for note.

For Example Open Notepad :-
Code:
#!/usr/bin/python3

print("This is Just my First Line")
''' Above i wrote my First Line in Python'''
print("\n You will not See above line when you execute python")
Beside above it is 3 single quote (')
save file with name "anything.py", and execute from CMD
Code:
1
c:\> python anything.py
This is Just my First Line
You will not See above line when you execute python

You see text written in 3 single Quote is not printed, because compiler does nothing for that, only you will see when you open source code of anything.py 

For this part 1, I end here, I know there is nothing for pre-coder, but I considering people with no programming stuff too. In my next part I will bring.

ITI 

1 comment:

  1. any suggestion to tell me improve my blogs thanks viewers

    ReplyDelete