<jupyter_start><jupyter_text>Variable TypesVariables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.Based on the data type of a variable, the interpreter allocates memory and decides what can be stored in the reserved memory. Therefore, by assigning different data types to variables, you can store integers, decimals or characters in these variables.  Assigning Values to VariablesPython variables do not need explicit declaration to reserve memory space. The declaration happens automatically when you assign a value to a variable. The equal sign (=) is used to assign values to variables.The operand to the left of the = operator is the name of the variable and the operand to the right of the = operator is the value stored in the variable. For example −<jupyter_code>counter = 100          # An integer assignment
miles   = 1000.0       # A floating point
name    = "John"       # A string<jupyter_output><empty_output><jupyter_text>Here, 100, 1000.0 and "John" are the values assigned to counter, miles, and name variables, respectively. This produces the following result −<jupyter_code>print(counter)
print(miles)
print(name)<jupyter_output>100
1000.0
John<jupyter_text>Multiple AssignmentPython allows you to assign a single value to several variables simultaneously. For example −<jupyter_code>a = b = c = 1<jupyter_output><empty_output><jupyter_text>Here, an integer object is created with the value 1, and all three variables are assigned to the same memory location.<jupyter_code>print(a)
print(b)
print(c)<jupyter_output>1
1
1<jupyter_text>You can also assign multiple objects to multiple variables. For example −<jupyter_code>a,b,c = 1,2,"john"<jupyter_output><empty_output><jupyter_text>Here, two integer objects with values 1 and 2 are assigned to variables a and b respectively, and one string object with the value "john" is assigned to the variable c.<jupyter_code>print(a)
print(b)
print(c)<jupyter_output>1
2
john<jupyter_text>Standard Data TypesThe data stored in memory can be of many types. For example, a person's age is stored as a numeric value and his or her address is stored as alphanumeric characters. Python has various standard data types that are used to define the operations possible on them and the storage method for each of them.Python has five standard data types −* Numbers* String* List* Tuple* Dictionary  Python NumbersNumber data types store numeric values. Number objects are created when you assign a value to them. For example −<jupyter_code>var1 = 1
var2 = 10
var3 = 20<jupyter_output><empty_output><jupyter_text>You can also delete the reference to a number object by using the del statement. The syntax of the del statement is −```del var1[,var2[,var3[....,varN]]]]``` You can delete a single object or multiple objects by using the del statement. For example −<jupyter_code>del var1
del var2, var3
print(var1), print(var2), print(var3)<jupyter_output><empty_output><jupyter_text>Python supports three different numerical types −* int (signed integers)* float (floating point real values)* complex (complex numbers) ExamplesHere are some examples of numbers −intfloatcomplex100.03.14j10015.2045.j-786-21.99.322e-36j08032.3+e18.876j-0490-90.-.6545+0J-0x260-32.54e1003e+26J0x6970.2-E124.53e-7j* A complex number consists of an ordered pair of real floating-point numbers denoted by x + yj, where x and y are the real numbers and j is the imaginary unit.  Python StringsStrings in Python are identified as a contiguous set of characters represented in the quotation marks. Python allows for either pairs of single or double quotes. Subsets of strings can be taken using the slice operator ([ ] and [:] ) with indexes starting at 0 in the beginning of the string and working their way from -1 at the end.The plus (+) sign is the string concatenation operator and the asterisk (*) is the repetition operator. For example −<jupyter_code>str1 = 'Hello World!'<jupyter_output><empty_output><jupyter_text>Prints complete string<jupyter_code>print(str1)<jupyter_output>Hello World!<jupyter_text>Prints first character of the string<jupyter_code>print(str1[0])<jupyter_output>H<jupyter_text>Prints characters starting from 3rd to 5th<jupyter_code>print(str1[2:5])<jupyter_output>llo<jupyter_text>Prints string starting from 3rd character<jupyter_code>print(str1[2:])<jupyter_output>llo World!<jupyter_text>Prints string two times<jupyter_code>print(str1 * 2)<jupyter_output>Hello World!Hello World!<jupyter_text>Prints concatenated string<jupyter_code>print(str1 + "TEST")<jupyter_output>Hello World!TEST<jupyter_text>Python ListsLists are the most versatile of Python's compound data types. A list contains items separated by commas and enclosed within square brackets ([]). To some extent, lists are similar to arrays in C. One difference between them is that all the items belonging to a list can be of different data type.The values stored in a list can be accessed using the slice operator ([ ] and [:]) with indexes starting at 0 in the beginning of the list and working their way to end -1. The plus (+) sign is the list concatenation operator, and the asterisk (*) is the repetition operator. For example −<jupyter_code>list1 = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
tinylist1 = [123, 'john']<jupyter_output><empty_output><jupyter_text>Prints complete list<jupyter_code>print(list1)<jupyter_output>['abcd', 786, 2.23, 'john', 70.2]<jupyter_text>Prints first element of the list<jupyter_code>print(list1[0])<jupyter_output>abcd<jupyter_text>Prints elements starting from 2nd till 3rd<jupyter_code>print(list1[1:3])<jupyter_output>[786, 2.23]<jupyter_text>Prints elements starting from 3rd element<jupyter_code>print(list1[2:])<jupyter_output>[2.23, 'john', 70.2]<jupyter_text>Prints list two times<jupyter_code>print(tinylist1 * 2)<jupyter_output>[123, 'john', 123, 'john']<jupyter_text>Prints concatenated lists<jupyter_code>print(list1 + tinylist1)<jupyter_output>['abcd', 786, 2.23, 'john', 70.2, 123, 'john']<jupyter_text>Python TuplesA tuple is another sequence data type that is similar to the list. A tuple consists of a number of values separated by commas. Unlike lists, however, tuples are enclosed within parentheses.The main differences between lists and tuples are: Lists are enclosed in brackets ( [ ] ) and their elements and size can be changed, while tuples are enclosed in parentheses ( ( ) ) and cannot be updated. Tuples can be thought of as __read-only__ lists. For example −<jupyter_code>tuple1 = ( 'abcd', 786 , 2.23, 'john', 70.2  )
tinytuple1 = (123, 'john')<jupyter_output><empty_output><jupyter_text>Prints complete list<jupyter_code>print(tuple1)<jupyter_output>('abcd', 786, 2.23, 'john', 70.2)<jupyter_text>Prints first element of the list<jupyter_code>print(tuple1[0])<jupyter_output>abcd<jupyter_text>Prints elements starting from 2nd till 3rd<jupyter_code>print(tuple1[1:3])<jupyter_output>(786, 2.23)<jupyter_text>Prints elements starting from 3rd element<jupyter_code>print(tuple1[2:])<jupyter_output>(2.23, 'john', 70.2)<jupyter_text>Prints list two times<jupyter_code>print(tinytuple1 * 2)<jupyter_output>(123, 'john', 123, 'john')<jupyter_text>Prints concatenated lists<jupyter_code>print(tuple1 + tinytuple1)<jupyter_output>('abcd', 786, 2.23, 'john', 70.2, 123, 'john')<jupyter_text>The following code is invalid with tuple, because we attempted to update a tuple, which is not allowed.<jupyter_code>tuple1 = ( 'abcd', 786 , 2.23, 'john', 70.2  )
tuple1[2] = 1000    # Invalid syntax with tuple<jupyter_output><empty_output><jupyter_text>Similar case is possible with lists −<jupyter_code>list1 = [ 'abcd', 786 , 2.23, 'john', 70.2  ]
list1[2] = 1000     # Valid syntax with list<jupyter_output><empty_output><jupyter_text>Python DictionaryPython's dictionaries are kind of hash table type. They work like associative arrays or hashes found in Perl and consist of key-value pairs. A dictionary key can be almost any Python type, but are usually numbers or strings. Values, on the other hand, can be any arbitrary Python object.Dictionaries are enclosed by curly braces ({ }) and values can be assigned and accessed using square braces ([]). For example − This is an empty dictionary.<jupyter_code>dict1 = {}
print(dict1)<jupyter_output>{}<jupyter_text>Assign a key/value to dictionary.<jupyter_code>dict1['dog'] = "I don't like dogs"
print(dict1)<jupyter_output>{'dog': "I don't like dogs"}<jupyter_text>Assign a second key/value to dictionary.<jupyter_code>dict1['cat']     = "I like cats"
print(dict1)<jupyter_output>{'dog': "I don't like dogs", 'cat': 'I like cats'}<jupyter_text>Predefine entire dictionary.<jupyter_code>tinydict1 = {'name': 'john','code':6734, 'dept': 'sales'}<jupyter_output><empty_output><jupyter_text>Prints complete dictionary<jupyter_code>print(tinydict1)<jupyter_output>{'name': 'john', 'code': 6734, 'dept': 'sales'}<jupyter_text>Prints all the keys<jupyter_code>print(tinydict1.keys())<jupyter_output>dict_keys(['name', 'code', 'dept'])<jupyter_text>Prints all the values<jupyter_code>print(tinydict1.values())<jupyter_output>dict_values(['john', 6734, 'sales'])
{'fraction_non_alphanumeric': 0.0961160811695396, 'fraction_numerical': 0.03676631027711106, 'mean_word_length': 6.483265306122449, 'pattern_counts': {'":': 0, '<': 126, '<?xml version=': 0, '>': 126, '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': '38', 'dir': 'jupyter-structured-clean-dedup', 'id': '541658', 'license': 'MIT', 'n_tokens_mistral': 3193, 'n_tokens_neox': 2893, 'n_words': 1002, 'path': '03 - Variable Types.ipynb', 'repo_name': 'maralski/python-tutorial-101', 'size': '9166'}