We know that variable is a named memory allocation which assigns a value and which may vary at the time of execution.
Exa: myVariable=100
If we call myVariable, then we will get 100
Python is case sensitive, that means there is a difference between uppercase and lowercase character.
For exa, if I will write MyVariable instead of myVariable, then it will give error.
We can perform mathematical operations using variable, like;
>>>myVariable+50
>>>150
>>>myVariable**2
>>>10000
The most important use of variable is to input a value. Exa;
Because here value is a string. So to perform addition operation we have to cast in to int, which is known as typecasting. After type casting we can perform any mathematical operations.
>>> value=int(input("Enter the value"))
Enter the value200
>>> value
200
>>> value+50*6
500
Defining a variable is a symbol, such as x, used to describe any number. When a variable is used in a function, we know that it is not just one constant number, but that it can represent many numbers.
There's no need to declare new variables in Python. If we're talking about variables in functions or modules, no declaration is needed. Just assign a value to a name where you need it: s= "Silan" . ... Variables have scope, so yes it is appropriate to have variables that are specific to your function.