Python Tutorial -1

As wiki state

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.

Setting your PC to run Python

  • Window user can download Python from here
  • GNU/Linux can download with simple command :
    dnf install python
    Or you can download straight from here
  • Mac user head over straight to this Link

Now as you all are ready with python now let’s have some fun
I am using on Fedora 23, but it same for other OS
So, GNU/Linux user head straight to terminal and type python3 and python interpreter will open.

To declare a variable and print it’s value

This will declare variable a with value 10
To print the value type a and press enter
In real world(when we write our program in file) we use print(a) to print the value of variable
now further you can play around python and learn more from resources on internet.

Let me show you some Pythonic way of coding.

  • Pythonic way to swap two number’s
    C++ way to swap two numbers
    int a=10;
    int b=20;
    int temp=a;

    But in python you can do this in one line

    Yea this way only one line can do this
    Python is amazingly great soon will share more pythonic way of coding.

Till than cheers!
Happy Coding