❮ Previous Next ❯

Python Variables and Inputs

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;
The most important use of variable is to input a value. Exa;

Now if we will perform any mathematical operation using value, then we will get error

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
>>> value+50*6

Rules for Python variables:

How do I define a variable?

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.

Do you have to declare variables in Python?

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.

❮ Previous Next ❯

Follow Us


Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Email: info@silantechnology.com
      Phone: 0674-2361252
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved