answersLogoWhite

0


Best Answer

A variable is used to store information. As an example say you are asking someone for their favorite food, and want to store the answer in a variable called favoriteFood:

favoriteFood = input("What is your favorite food?")

Now if you print the value of favoriteFood (using print(FavoriteFood)) you will see that it has been saved in that variable. You can store any type in a variable, such as number, a string, or even an object.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

In Python, a variable is a named reference to an object, or a named reference to None.

This answer is:
User Avatar

User Avatar

Wiki User

7y ago

The easiest way to explain it is it carries a value. If you want to use it throughout your code and classes you can declare the variable as global.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a variable used for in Python?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you modify strings so that they are accepted as variable names when programming in Python?

You can use the exec statement in Python to create variables from strings. For example, exec("a = 100") creates a variable named a with a value of 100.


How do you decrement on python?

-= Example: variable = 5 variable -= 2 will out put 5


How do you define a symbol such as plus or - as a variable in python?

Use a character variable. For example: plus = '+' minus = '-' You can now refer to these symbols using the variable names "plus" or "minus".


How do you define Y as 1 and N as 0 in Python?

I suspect that you mean that you want to define constants, which is not possible in Python. Any variable can be rebound to something else at any time.


What is optional for python programming?

One optional part of python programming is the declaration of variables before use. In many languages, you must declare your variables before using them, but in python, you can simply set a variable equal to something and it will handle the type without your help.


Is python 2.2 a antivirus software?

Python is a programming language, it is used to make computer programs. so you could write an antivirus using python.


What strategies were used during the civil war?

the strategy that was used by the north to defeat the south was the python. the python is when the north surrounded the South and slowly moved in and destroyed the south just like a python does to its prey.


What is used in python programming for space in output?

I interpreted your question as this: What is used in Python for adding a blank line to the output? If you are looking for this, a simple print statement will do: print #in python 2.x or print() #in python 3.x If that wasn't what you were looking for, change the question to be more clear.


Which symbol is used with a variable to indicate to the script that you are reading the contents of that variable?

Which symbol is used with a variable to indicate to the script that you are reading the contents of that variable?


Which technology is used for developing orkut?

python


What wars used the colt python?

None


What is a n independent variable?

an independent variable is a figure usually shown as a letter that is used in the scientific theory. An independent variable is used in a hypothesized experiment in which this variable is unchanged and is used to effect the dependent variable somewhere in the experiment.