BASICS OF PYTHON

BASICS OF PYTHON

  • We are going to take a free course on python programming language,so before we go in deep with it,we should learn some basic.
 
 
  •  Does`nt matter if you use a different version, since we showed some of the demo on 3.4.0. and so we recommend it.


So lets start

Before going to demo, let us know about Python.

Python is a widely used high-level, general-purpose, interpreted, dynamic programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than possible in languages such as C++ or Java.

Basic 1:

A kind of Hello World program is the base for all programming language, and here we used our blog name to demonstrate it.

 For printing a string or number we can just use the syntax as shown in screenshot below:
                                          >>>print("Mypcethics")


Output:

Mypcethics




Basic 2:

To initialize variable we just need to state variable.
 Here VAR is the variable name.it can also be a=12,b=12 anything of your own etc.,

NOTE: a variable name does`nt start with number example 1var=12.(wrong)

>>>var=12
now var variable sets value as 12


if we want to print it, just use the syntax as shown in screenshot
>>>print(var)
 12

Output:


Basic 3(Getting Input from User):

To get input for user in C we use scanf and in JAVA use inputstream,Scanner class....etc,

In python,we use input, irrespective of the data (String or number)


 Lets, Create a new file with program below and save it as .py extension.


Step 1: Open Python, File -->New Window (CTRL+N) and type the below Code.

Program(input.py):


print("enter your name");
var=input();
print("your name is",var);


Save it as input.py

NOTE: You can save your code in any file name u like.in my case ,I used input.py
              No restrictions like seen in Java!
 
To RUN Code:
  •   click run -->click run module(F5).
Output:


Let us, see some loops and conditions on next post.
Until then stay tuned on MyPCEthics for learning python and penetration testing using Python.

Like and Follow us on Facebook: https://www.facebook.com/mypcethics

 ANYTHING IS POSSIBLE IF YOU TRY HARD ENOUGH

No comments: