Python : Crash Course Part 2 – Variable Assignment

Have you tried out the arithmetic operations on python yet ? If not, I strongly recommend you to visit the first part of the crash course. For the rest of you, let’s get started.

The assignment operator in python is the “equal to” ( = ) sign as shown below:

In [1]: var = 2
In [2]: var
Out[2]: 2

Some more examples:

In [3]: X=4
In [4]: X+Y
Out[4]: 14

If your variable comprises of multiple words then separate the words with a “under score” ( _ ) symbol as shown below :

In [5]: multiple_words_var = 10


1) Variable names shouldn’t start with numbers.
2) Variable names cannot start with special symbols as well.
3) Variable names are case sensitive.

Feels like we are using C programming, aren’t we ? It’s that simple. Let’s go to strings now.

Leave a Reply

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

You are commenting using your 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