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
- Alphabet – A to Z or a to z
- Digit – 0 to 9
- 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.
Variable
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.
How simple is it, isn’t it? In the above example, we have declared a variable named, v and assigned a value, 7 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.
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.
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.
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
The output is
In the above program, the Variable a, b, and c is assigned the same value i.e., 400.
Vaibhav says:
Taranjeet Kaur says:
FESTUS EDEAWE says: