After learning the introduction of Python in the previous article, we are going to learn about the Basics of Python, which is, Characterset, Keywords, and Variables.

Basics of Python

Following are the Basics of Python covered in the article.

 Character set

  1. Alphabet – A to Z or a to z
  2. Digit – 0 to 9
  3. Special character – +,-,(,),[,],{,},%,@,!,&,^ ,;. ” , | / ,>, < etc.

 Keywords or Reserved word

A keyword is a reserved word, which has a special meaning. There are 33 keywords, and all have special meaning. Here is the table below showing the keywords.

basics of python

Variable

 A variable is a memory location, which is used to store any kind of data items, like an integer, a float, a string, or a character etc., in it.  During the execution of the program, the value of the variable changes.

It is easy to define the variable and initialize it. For example, suppose, you want to store 7 in a variable named v. Let’s do it.

basics of Python

How simple is it, isn’t it?  In the above example, we have declared a variable named, and assigned a value, in it.

Besides it, meaning, an integer variable, we can also, declare a variable of string type, a boolean type, true or false, and a float type.  Let’s state it with an example.

basics of Python

In the above example, 10 is stored in a variable named a, Hello world in a variable named b, and, 56.5 is stored in a variable named c and True is stored in a variable named d.

The output is.

basics of Python

Python, automatically, knows the data type of a variable, for example, a is assigned a value 10 in it. Python will automatically know that the a’s data type is an integer.

Assigning Multiple values to multiple variables

In Python, one can assign multiple values to the multiple variables. It is cited in the example given below.

basics of Python

The output of the above example is

Assign multiple variables with the same value

One can assign the same value to multiple variables. Let’s do it

basics of Python

The output is

basics of Python

In the above program, the Variable a, b, and c is assigned the same value i.e., 400.

Recent Tweets

Recent Posts