This Python Tutorial by Mayank Gupta contains the concept about Variables in Python in English, Rules of naming variables, Reusing variables, Combining variables and Typecasting variables in Python.
Today's subtopic :
1. What is variable?
2. Rules to name a variable.
3. Reuse a variable.
4. Rules of combining variables
5. Typecasting.
1) What is Variable?
Variables are used to store information to be referencedand used by programs.
It can be used to hold a value.
A variable can be your name, it can be your city name, or many thing but have some rules.
x = 10
We are storing into variable x the integer value 10
y = 50.0
Here, we are storing float(Decimal) value 50.0 into variable y.
z = “My name is Ram.”
Here, we are storing string “My name is Ram.” into variable z.
2) Rules to name a variable.
There are some rules for naming a variable:
1. A variable name must start with a letter or the underscore character.
2. A variable name cannot start with a number.
3. A variable name can only contain alpha-numeric characters (A-z, 0-9) and underscores ( _ )
4. Variable names are case-sensitive.
3) How to Reuse a Variable
In Python, We can reuse the same variable name to store values of any type. And we can use the same variable multiple times.
4) Rules of Combining Variables:
There are some rules of combining variables :
1. We cannot combine string and integer directly.
2. We cannot combine string and float(decimal values) directly.
3. But we can combine integer and float directly.
5) Typecasting
To combine string and integer we have to do typecasting
(means type conversion). So we will convert integer into
string by putting the integer variable in str( ).
And same process is required for converting float to string.
This is the second lecture of the Python series of 13 Videos.
Please Like, Comment, Share and Subscribe to my Channel.
My profile : https://www.xsonic.in/profile/
Thank You
Mayank Gupta