<jupyter_start><jupyter_text>As the name implies, a variable is something that can change. A variable is just a way of referring to a memory location used by a Python program. Based on the datatype of the variable, the Python interpreter allocates the memory and decides what can be stored in the reserved memory. This makes Python a dynamically-typed languageIf you are familiar with other programming languages like C, C++ or Java it might be tempting to consider variable as just a container to store data. However in Python, you can at best, think of variables as pointers. This is why you can dynamically change the type of data that a variable is pointing at.   Assigning values to variablesOne of the main differences between Python and strongly typed languages like C++ or Java is the way it deals with the data types. In languages like C++ or Java, every variable must have a unique data type (i.e if a variable is of type string it cannot store integers or floats). Moreover, every variable has to be declared before it can be used, thus binding it to the data type that can be stored in it. Python variables do not need explicit declaration to reserve memory space. The declaration happens automatically when a value is assigned to a variable. This means that a variable that was used to store a string can now be used to store an integer. Try it out.Do something like this<jupyter_code>var = 'I am in NYC'
print(var)<jupyter_output>I am in NYC<jupyter_text>**var** is a string in the above case.Well.. don't take our word for it. Let's confirm. If we run the next line,<jupyter_code>type(var)<jupyter_output><empty_output><jupyter_text>As we saw in the grid in the 01.00, Type is a built-in function that returns any datatype If we point our variable var to, lets say, an integer, it will return int<jupyter_code>var = 123
type(var)<jupyter_output><empty_output><jupyter_text>**So what are the rules of naming a variable?**Every language has some rules for naming the identifier of variables (aka the variable name). In Python, a valid identifier is a non-empty sequence of characters of any length with:The start of the character can be an underscore _ or a capital or lowercase letter. However, it is generally recommended to use all uppercase for global variables and all lower case for local variables. The letters following the first letter can be a digit or a string. Python is a case-sensitive language. Therefore, **var** is not equal to **VAR** or **vAr**.Apart from the above restrictions, Python keywords cannot be used as identifier names. These are:|||||||:-------|:--------|:---------|:--------|:----||and     |del      |from      |not      |while||as      | elif    |global    |or       |with ||assert  | else    | if       |pass     |yield||break   | except  | import   |print|class   | exec    | in       |raise|continue| finally | is       |return |def     | for     | lambda   |try   MultiplesPython allows you to assign a single value to several variables simultaneously. For example:<jupyter_code>x = y = z = a = 1<jupyter_output><empty_output><jupyter_text>or even assign different values to different variables:<jupyter_code>x, y, z, a = 'Hello', 'World', 1, 2
print (x,y,z,a)<jupyter_output>Hello World 1 2
{'fraction_non_alphanumeric': 0.0743368291178285, 'fraction_numerical': 0.003701418877236274, 'mean_word_length': 3.9892307692307694, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '144726', 'license': 'MIT', 'n_tokens_mistral': 864, 'n_tokens_neox': 829, 'n_words': 480, 'path': 'notebooks/01-01 Variables.ipynb', 'repo_name': 'Mohitsharma44/ucsl17', 'size': '3242'}