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
a=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;
    a=b;
    b=temp;

    But in python you can do this in one line
    a=10
    b=20
    a,b=b,a

    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

4 thoughts on “Python Tutorial -1

  1. You really make it seem so easy with your presentation but I find this matter to be really something which I think I would never understand.
    It seems too complicated and extremely broad for me.

    I am looking forward for your next post, I’ll try to get the hang of
    it!

    Like

    1. First you need to link any of your email account with Firefox and then sync the data in that account. So whenever you log in into your Firefox account in a new computer the data will auto sync.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.