Python – Variables

You can think of variables as an address in your memory that contains data that you’ll need and use. The syntax for using variables in python in very straightforward. If you are a beginner, you should begin here:
https://arjunaraneta.wordpress.com/2014/08/02/python-basic-output-print/

Here is a basic example of declaring a variable named x with a value of 10. After declaring and assigning a value, the program will output the value of x.

var1

 

The output should be the same as below:

var2

 

On the next example below, I declared two variables named x and y. I assigned a value for each of the variables. After assigning the values, I created another variable named z assigned the sum of x and y. The program will output the result after the addition.

 

var3

The output should be the same as below:

var4

 

 

Thank you for reading my blog. Don’t forget to leave a comment.

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s