Python tutorial-Variables

Variables in Python

Variables in python are loosely type like JavaScript. You don’t need to specify the data type when you declare a variable. However, when you declare a variable, you must initialize its value. Otherwise, Python doesn’t treat it as a variable and you get an “not defined name” error message.
>>> x
Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
NameError: name 'x' is not defined
Once the variable is proper initialized, it is simple to access its value:
>>> x=10
>>> print x
Or, you just type:
>>> x=10
>>> x
10 >>>


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.