<jupyter_start><jupyter_text>Basic Python for Machine LearningAuthor - <NAME>Python is an interpreted, high-level, general-purpose programming language. Created by <NAME> and first released in 1991, Python has a design philosophy that emphasizes code readability, notably using significant whitespace. It provides constructs that enable clear programming on both small and large scales.This is a ipython notebook for learning python for Machine Learning.   Checking KeywordsIn programming, a keyword is a word that is reserved by a program because the word has a special meaning. Keywords can be commands or parameters. Every programming language has a set of keywords that cannot be used as variable names. Keywords are sometimes called reserved names .<jupyter_code>import keyword

print("Keywords are\n",keyword.kwlist)

print ("\n Total Number of Keywords",len(keyword.kwlist))<jupyter_output>Keywords are
 ['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

 Total Number of Keywords 33<jupyter_text>For Loop in Python<jupyter_code>#here in python there have only two line of code for run a for-loop
for i in range (10):
    print("Demo",i)<jupyter_output>Demo 0
Demo 1
Demo 2
Demo 3
Demo 4
Demo 5
Demo 6
Demo 7
Demo 8
Demo 9<jupyter_text>Multi Line Statement<jupyter_code>#here i am going to show you how to write multi line statement in python
a = 3+2+3+2+ \
    3+2+3+2+ \
    2+2

print (a)

#another way to do 
a = (3+3+3+3+5+
     6+6+7+9+8)

#another ways to do 
a =10 ;b =20; c =30 #multiple statement in a single line
print(a+b+c)<jupyter_output>24<jupyter_text>If else Statement<jupyter_code>a=int(input("Enter the value"))#here i am taking a input to check the if else conditions
#if statement
if a<=5:
    print("Lower")
#else statement    
else:
    print ("Higher")<jupyter_output>Enter the value10
Higher<jupyter_text>Length of the Statement<jupyter_code>string=("Hello")
print (len(string))#len is a length function for finding the length<jupyter_output>5<jupyter_text>Storage Location<jupyter_code>val=6
print (id(val)) #id is the address of variable val<jupyter_output>10910560<jupyter_text>Data Types In computer science and computer programming, a data type or simply type is an attribute of data which tells the compiler or interpreter how the programmer intends to use the data. Most programming languages support common data types of real, integer and boolean.<jupyter_code>a=15 #integer
var="Hello" #String
var_1= 12.56 # float
var_2= 9+1j #complex number
print (a,"Data type",type(a))
print (var,"type",type(var))
print (var_1,"type",type(var_1))
print (var_2,"type",type(var_2))<jupyter_output>15 Data type <class 'int'>
Hello type <class 'str'>
12.56 type <class 'float'>
(9+1j) type <class 'complex'><jupyter_text>Boolean<jupyter_code>a= True

print (type(a))<jupyter_output><class 'bool'><jupyter_text>String In computer programming, a string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. The latter may allow its elements to be mutated and the length changed, or it may be fixed.A string is a data type used in programming, such as an integer and floating point unit, but is used to represent text rather than numbers. It is comprised of a set of characters that can also contain spaces and numbers. For example, the word "hamburger" and the phrase "I ate 3 hamburgers" are both strings.<jupyter_code>strg = "Hello welcome to my ipython notebook"
print (strg)
#slicing
strg[5:]<jupyter_output><empty_output><jupyter_text>Python ListPython Collections (Arrays). There are four collection data types in the Python programming language: List is a collection which is ordered and changeable.<jupyter_code>lis = ["hello","how","are","you"]

print(lis[0:3]) # Index starting from 0<jupyter_output>['hello', 'how', 'are']<jupyter_text>Python TuplesA tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use **square brackets**.**Tuples vs List**Python tuples vs lists – Mutability. The major difference between tuples and lists is that a list is mutable, whereas a tuple is immutable. This means that a list can be changed, but a tuple cannot.<jupyter_code>t = ("hello","hi","how","are","you",5) #tuples

print (t[3]) #tuples index number<jupyter_output>are<jupyter_text>Python SetsSets in Python. A Set is an unordered collection data type that is iterable, mutable, and has no duplicate elements. ... Frozen Sets Frozen sets are immutable objects that only support methods and operators that produce a result without a?ecting the frozen set or sets to which they are applied.**Access Items**You cannot access items in a set by referring to an index, since sets are unordered the items has no index.But you can loop through the set items using a for loop, or ask if a specified value is present in a set, by using the in keyword.**Note**: *Sets are unordered, so the items will appear in a random order.*<jupyter_code>sets = {"hello","hii","how",5,6,7}

print (sets)
print (type(sets))<jupyter_output>{'hii', 5, 6, 7, 'hello', 'how'}
<class 'set'><jupyter_text>Sets are unordered  Python Sorting<jupyter_code>a = [1,0,6,2,3,4,10,7,5]

sort= a.sort() #sorting function

print (a)<jupyter_output>[0, 1, 2, 3, 4, 5, 6, 7, 10]
{'fraction_non_alphanumeric': 0.1030725259021079, 'fraction_numerical': 0.020364415862808145, 'mean_word_length': 5.67342073897497, 'pattern_counts': {'":': 0, '<': 50, '<?xml version=': 0, '>': 49, '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': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '300068', 'license': 'MIT', 'n_tokens_mistral': 1803, 'n_tokens_neox': 1706, 'n_words': 736, 'path': 'iNotepy.ipynb', 'repo_name': 'suvhradipghosh07/iNotepy-Python-for-Quick-Reference', 'size': '5617'}