Keywords and Identifiers

Variables Introduction:

Before proceeding with keywords we will have a look at variables. A variable is a name that refers to some value stored in the memory location. Technically a variable is something that holds the reference to a memory location used by a computer program. We can store any type of value in this variable. Let's look at the below example.

age = 25;

In this example, we are storing the value 25 into the variable named age. The sign = assigns the value from right hand side to the variable on the right hand side and is not same as the mathematical sign equal to. As the name suggets the value held by a variable can change during the execution of the program. Generally in other programming languages if we need to use a variable, we first declare the type of the variable i.e. the type of the value that is stored into this variable and then assign the value to it.

Example:
	int age;
	age = 20;

In the above example we are declaring that the variable age will hold the integer data. And then assigning the value 20 which is an integer. If we try to assign a value other than integer the program will throw us an error. But in python everything is simple. We do not need to declare the type of variable before assigning a value. And we can assign any type of data to the variable. The program will take care of everything internally. The following example will give us a better understanding.

	age = 25
	age = "twenty five"

In the first statement we assigned a value 25 which is an integer to the variable age without declting the type as in other programming languages. And in the stament two we reassigned a value "twenty five" which is a string to the same variable and the python interpreter will not throw us any error as in other programming languages. The type function is used to identify the type of the data assigned to the variable.

>>> age = 25
>>> type(age)
<class 'int'>
>>> age = "twenty five"
>>> type(age)
<class 'str'>

The memory address to which the ariable is poiniting to can also be seen by using the identity function as shown in below examples.

	
	id(age)
	

    An identifier is a name used to identify a variable. An identifier can consist of the uppercase letters "A-Z", the lowercase letters "a-z", the underscore _ and the digits 0 to 9. The identifiers are case-sensitive and cannot start with a digit or contain whitespace. Python 3.x is based on Unicode and allows all the unicode characters in defining variable names as long as the names are not starting with the digits or containing a white space. Note that an identifier can also refer to the name of a function, class or any other objects which we will discuss in the upcoming chapters. The following examples are valid identifiers:

Python releases:

The first standard version 1.0 is released in 1994 July and the version 2.0 is released in 2000 October. The last major release for python 2.x is released in September 2017 as 2.7.14. The 2.x branch will see no new major releases after that. The first 3.x version is released in 2008 as 3.0 which is under active development and has already seen over six years of stable releases, including version 3.6.3 in 2017 November.

The Zen Python:

The Zen of python is a collection of principles written by Tim Peters which influenced the Python design. The principles are listed below.

help> keywords

Here is a list of the Python keywords.  Enter any keyword to get more help.

False               def                 if                  raise
None                del                 import              return
True                elif                in                  try
and                 else                is                  while
as                  except              lambda              with
assert              finally             nonlocal            yield
break               for                 not
class               from                or
continue            global              pass

This can also be displayed by entering a stement import this in python interpreter.

Introduction Data Types