Introduction :

Hey, my name is Sagar Bansal and I will help you through this Journey in Learning Python in Just One Hour.

Being an Ethical Hacker, I know a lot of Languages but Python was something which i never though a need to learn myself due to C++ and Java which i spent years mastering,
and My Friend Nic, the Founder of CoursePlaza Youtube Channel requested me to Make a Guide on Python.

But Wait! I don’t know python myself, So I started to Learn Python, and after 4-5 Hours, I Realized that it is now my Favorite Language, and the Good News is, I will Teach you Python, in a Completely Different Manner which Allow you to Learn Python at a Super Human Speed!

Install Needed Packages :

Well We need some Packages to Start Learning Python in the Most Appropriate Way!

I am going to do everything on Windows but you can do it on Mac as well as Linux because these all software which we are going to use are fully compatible with all the major platforms  

So first thing which we need Eclipse IDE which you can get from https://www.eclips/download/
Just download the latest one which ever available for you.

Then you need python so go to https://www.python.org/download and download the latest version which ever available for you.

Last thing is java and you may not need it, so you can open the Eclipse Installer and it will automatically ask you to install Java it you don’t have that already

So Now install Everything one by one and I Recommend the Installation Order as python -> java -> eclipse

Now I assume you can install these yourself but if you face problems, you can always see the Video above

In the case of eclipse we will install the eclipse with eclipse IDE for JavaScript and Web Developers

Now We Need to Install PyDev in Eclipse…

Setup PyDev with Eclipse :

Now Let’s Install PyDev in our Eclipse IDE to Start Working with Python Programs

For this  just want to open your eclipse IDE and go to  help and click on install new software and it is asking you for a URL for work with so you can enter the official URL i.e.  http://pydev.org/update
then click on add and then click on OK

After that as we only want to do python development so click on first option PyDev and then click on next

Then you can go with PyDev for Eclipse and click on next then read the both license and accept them. You can see bottom right corner installing software it will take 5 min so you need to wait for it. As soon as it completes, it will ask you to restart your IDE

After restart, go to file and then click on new and finally, click on other

Select PyDev project and click on next and give it a project name like test project.
then click on configure an interpreter before proceeding and click on manual configure

In manual configure click on new and click on browse and find the file where is python is installed ( for me it was in C:\Users\bansal\AppData\Local\Programs\Python\Python36-32 ) and select the python.exe ( in case of Windows ) and then give a name interpreter python interpreter and click on OK

On the next page select the all and click on OK

So Now  everything has been loaded then click on apply and close

Then select the python interpreter in interpreter and select the python version 3.6 in grammar version and then click on finish

Well now we are All Set to Learn Python…

Taking Input and Printing Output :

Well Input and Output is the Step Stone for Learning Python

First of all open your eclipse-workspace-eclipse and right click on test project go to new and click on PyDev module 

Give it a name like (test) and click on finish after that its asking you for a template if you no need template then go to empty and click on OK

 

If text is small and you want to change the font size then go to  window click on preferences and then search for font and click on text font then click on edit and you can increase the size of the font 

So lets talk about the input and output before that we need to talk about variables

 To Explain Variables just think about some storage devices you have a pc which is your python program and you have a pen-drive which has some kind of data, Now that pendrive is a variable and you can storage the data in pen-drive through PC.

so if I type

a = 2
b = 5

now I am making a variable  which is just like a storage device like a is a  pendrive which has a data similarly b has a data which is 5 and  c can have a data  like “sagar bansal” and  whatever you type in your code will get stored in the variables.

Now we can use print function in next line you print the value of  a like print(a)

And now go to run  ->  click on run -> click on python run – > click OK and in console comes the value of a is 2

(You can also use Crtl + f11  or Cmd + f11 shortcut keys)

If I print(b) and press Ctrl + f11 the value changes to 5 in console

And if I print(c) the value changes to my name

So lets try a very basic thing like if I just type x = a+b and then print(x) and press Ctrl+f11 and value of x show in console 7

If I try to do  this thing x = a+c then you get an error because you cannot add  a number and a string

So this is all about printing and now let’s talk about input

You can type like

a = input()
b = input()
print(a)
print(b)
and run it


and now it will ask you for value of a and b because of input function

And if I want to show something then I type for example

a = input(“please enter first data : ”)
b = input(“please enter second data : “ )

press  Ctrl+f11 then in first data I  will type sagar and second data I will  type bansal  and press enter and the output is sagar bansal

Basically in print and input there is a  lots much to learn

Just like if I type  print( a+b) in the code and press Ctrl+f11 then again type sagar in first data and  bansal  in second data  and press enter then result is sagarbansal

but if I do this thing with number 1 in the first data and 2 in the second data and press  enter then result is 12,not 3

So  here you can do it a very  small trick like

x = int(a)
y = int(a)
print = x+y

and press Ctrl+f11
type 1  in first data and 2 in second data and press enter and the value of x+y is comes in 3

You can also Reassign the Value as a = int(a) to avoid taking a lot of variables in the program

Now try to type the print (a*b)
Press Ctrl+f11 and type in first data and 5 in second data press enter and result is to be 45.
so  in this we multiply the first and  second number

try print(a , “multiply” , b ,  “=”  ,  a*b )
press Ctrl+f11 and  then 10 in first data and 15 in second data press enter result is to be 10 multiply 15  = 150

so , can be used for printing a lot of things on same line, and what ever you type in ”  ”  will get printed as it is

Now When you know how to work with Data, Let’s Give our Program some Intelligence with Conditions…

Conditional Statements:

Let’s understand some Conditional Logic and make a CLI Calculator

In any language there are three basic conditional statement which are if,else and else if which is also called elief in python

So  let’s talk about with real practical example so let’s have a , b and c

a = input( “please enter first number : ”)
b = input( “please enter second number : “ )
a = int(a)
b = int(b)
c = 0

x =  input ( “please  entre an operator : “ )

Now lets try type if x == make sure whenever you compare  something  you should use double equal sign like this  (==) after that type “+” and  then add a colon here (:)  and press enter and  you will see in next there is a is a space and it means you are in the if function then type c = a + b  then I will just exit the if and print (c) and  press ctrl+f11 and lets add the number 2 and 5 in console and add in operator + then press enter result is to be 7 which is the answer .

Lets add more logic here,
you can use if statement, but let’s do it with elif

if x  == “-“  :
  
c = a  – b
print (“ the answer is : “ , c )

run this up and Give Input :
first one is 6 and second 4 and then subtract (-)
the answer is 2

Now add some more logic here let’s add

elif x == “-“ :
   c = a – b
elif x == “ *” :
  
c = a *b
elif x == “/” :
   c = a / b
elif x == “%” :
   c = a % b

Now thinking about a situation that user may not give any valid operator, then we should have a Error also, so

else:
    c = “you gave a wrong operator” 

But If we are Assigning that Error Message i.e. you gave a wrong operator
we will actually have to remove the value of c so c = “ “
which means
that we are not giving any kind of value to it and hence no Default Data Type is initialized

 

Lets try to run it press ctrl+f11 type 5 in first data and 2   in second and divide them / answer is 2.5

Hope you have already understood everything at this moment so we have a that is an input from user which is the  first  number and we have b that is also an input from the user which is the second number

but there is a problem in this,
if I just enter 10.5 which is float not an integer and enter 11 and press enter it says  invalid because you know int with base 10.5 not gonna work

Here you can actually give it a float like 


a = float (a)

b = float (b)

and now the calculator will be fine with decimals
because  float means the number which contain decimal

 

Now that you know, how to give intelligence to your program, Let’s unleash the power using loops

Conditional Statements:

Let’s understand some Conditional Logic and make a CLI Calculator

In any language there are three basic conditional statement which are if,else and else if which is also called elief in python

So  let’s talk about with real practical example so let’s have a , b and c

a = input( “please enter first number : ”)
b = input( “please enter second number : “ )
a = int(a)
b = int(b)
c = 0

x =  input ( “please  entre an operator : “ )

Now lets try type if x == make sure whenever you compare  something  you should use double equal sign like this  (==) after that type “+” and  then add a colon here (:)  and press enter and  you will see in next there is a is a space and it means you are in the if function then type c = a + b  then I will just exit the if and print (c) and  press ctrl+f11 and lets add the number 2 and 5 in console and add in operator + then press enter result is to be 7 which is the answer .

Lets add more logic here,
you can use if statement, but let’s do it with elif

if x  == “-“  :
  
c = a  – b
print (“ the answer is : “ , c )

run this up and Give Input :
first one is 6 and second 4 and then subtract (-)
the answer is 2

Now add some more logic here let’s add

elif x == “-“ :
   c = a – b
elif x == “ *” :
  
c = a *b
elif x == “/” :
   c = a / b
elif x == “%” :
   c = a % b

Now thinking about a situation that user may not give any valid operator, then we should have a Error also, so

else:
    c = “you gave a wrong operator” 

But If we are Assigning that Error Message i.e. you gave a wrong operator
we will actually have to remove the value of c so c = “ “
which means
that we are not giving any kind of value to it and hence no Default Data Type is initialized

 

Lets try to run it press ctrl+f11 type 5 in first data and 2   in second and divide them / answer is 2.5

Hope you have already understood everything at this moment so we have a that is an input from user which is the  first  number and we have b that is also an input from the user which is the second number

but there is a problem in this,
if I just enter 10.5 which is float not an integer and enter 11 and press enter it says  invalid because you know int with base 10.5 not gonna work

Here you can actually give it a float like 


a = float (a)

b = float (b)

and now the calculator will be fine with decimals
because  float means the number which contain decimal

 

Now that you know, how to give intelligence to your program, Let’s unleash the power using loops

Unleash the Power of Loops:

Let’s get our program to have immense powers

Python at Super Human Speed:


Close Menu
Only Serious People Please!

Career Plan To Get $100K in Information Security

Where Shall I Send You This Plan?
SEND ME NOW!
No, Do Not Want To Make Any Career In It
This is Available For 24 Hours Only...

Ethical Hacking Training Only For Serious Students!

Register For This Exclusive Event For Free
SEND ME NOW!
No, Do Not Want To Make Any Career In It