<jupyter_start><jupyter_text>Python is a general-purpose, versatile and popular programming language. Python comes in two version 2.x and 3.x For demo we are using python 3.x  VariablesA variable stores a piece of data, and gives it a specific name.Here are examples of python variables.<jupyter_code>var1=10
var2="hello" #strings
var3=12.4344
var4=True  #boolean value<jupyter_output><empty_output><jupyter_text>print statement:<jupyter_code>print(12)
print("hello world\n\n") #newline "\n"
print(1+5)
var=100.23
print(var)<jupyter_output>12
hello world


6
100.23<jupyter_text>Comments<jupyter_code>print("this is not comment") #this is comment,  
4
"""
this is multiline comment
"""<jupyter_output>this is not comment<jupyter_text>Arithmetic Operations<jupyter_code>add = 72 + 23
sub = 108 - 204
multi = 108 * 0.5
div = 108 / 9


print(add, div, multi, div,5%4)

eight = 2 ** 3 #power operator

eight<jupyter_output>95 12.0 54.0 12.0 1<jupyter_text>Strings<jupyter_code>c="cat"
print(c[0])    # printing first character of "cat"
d="dog"
print(c+d) #concatenation
length = len("count_the_letters")  #length of the strings

length<jupyter_output>c
catdog<jupyter_text>some more operation<jupyter_code>mystr="BigData"
lower= mystr.lower()
print(lower)
print("BigData".upper())
#Alternate print statement
n="Anonymous"
a=-1
print("My name is %s and age is %d"%(n,a))  #Remember C...<jupyter_output>My name is Anonymous and age is -1<jupyter_text>Type Casting<jupyter_code>a=10
print(type(a))
a=str(a)
print(type(a))
# Taking input from keyboard

ip1=input("Enter something  ")
print(type(ip1))

ip2=input("Enter a number   ")
print(type(ip2)) 


#thats why we need type casting

ip2=int(input("Enter a number  "))
print(type(ip2))<jupyter_output>Enter something  10
<class 'str'>
Enter a number   10
<class 'str'>
Enter a number  10
<class 'int'><jupyter_text>Python list or is it Array<jupyter_code>numbers = [5, 6, 7, 8]
print(numbers) #prints the whole list

print(numbers[0]) #prints first element of the list

print(numbers[0:3])  #prints first three elements. This is called list slicing 

#list are not array
notArray=["big", 2, 2.43, False]
print(notArray)<jupyter_output>[5, 6, 7, 8]
5
[5, 6, 7]
['big', 2, 2.43, False]<jupyter_text>more on python list<jupyter_code>mylist=[12,5,4,1,54,2]

mylist[-1]=100  #changing the last element

print(mylist) 

mylist.sort()  #sorts the list
print("sorted list is ", mylist)

print("length of list is %d"%len(mylist))

#appending elemets to list
#taking mylist

mylist.append("Iam_last")
print(mylist)<jupyter_output>[1, 4, 5, 12, 54, 100, 'Iam_last']<jupyter_text>Multidimensional list<jupyter_code>mylist=[[1,2,3],[4,5,6],[7,8,9]]

print(mylist[0])  #prints first row

print(mylist[0][0]) #prints first element of 3x3 matrix


#more on multi dimensional array/list  will be in numpy tutorials<jupyter_output>[1, 2, 3]
1<jupyter_text>Dictionaries Dictionary uses key/value pairs to store data.Like Lists, Dictionaries are mutable.This means they can be changed after they are created.<jupyter_code>Dict={"first":1,"second":2,'third':"bid_data"}  #declaration or assignment

print(Dict)

Dict['first']=-1     #changing value of 'first'
print(Dict['first'])
      
del Dict['first']
#print(Dict['first'])<jupyter_output>{'second': 2, 'first': 1, 'third': 'bid_data'}
-1<jupyter_text>Control statements Python if-else if condition(s):        statements    else:        statements   Note: Be carefull about indentaion.<jupyter_code>if 1>2:
    print("you are alien")
else:
    print("we all know that")
#more on if-else

if 1>2 and 1<2:     #see the usage of 'and' 
    print("will not run")

elif 1>=2 or "a"=="b":
    print("will not run")

elif 'a' != 'b':
    print("hi.....")

else:
    pass       #this will do nothing<jupyter_output>hi.....<jupyter_text>Loops<jupyter_code>#while loop
i=10
while(i>0):
    print(i,end=' ')
    i=i-1

# for loop 
for i in range(1,11):
    print(i,end=' ')<jupyter_output>1 2 3 4 5 6 7 8 9 10<jupyter_text>more on for loops<jupyter_code>mylist=[]
for i in range(10,0,-1):
    mylist.append(i)

for i in mylist:
    print(i,end= ' ')<jupyter_output>10 9 8 7 6 5 4 3 2 1<jupyter_text>Functions<jupyter_code>#definition
def myfunc():
    #statements
    print("are u calling me")    
    return 

#calling
myfunc()
#function returing values
def square(arg):
    arg=arg**2
    return arg


print(square(4))<jupyter_output>16
{'fraction_non_alphanumeric': 0.14032697547683923, 'fraction_numerical': 0.04518619436875568, 'mean_word_length': 5.230551626591231, 'pattern_counts': {'":': 3, '<': 51, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '169137', 'license': 'MIT', 'n_tokens_mistral': 1822, 'n_tokens_neox': 1684, 'n_words': 456, 'path': '1. basics_of_python.ipynb', 'repo_name': 'therajmaurya/Machine-Learning-Workshop-Content', 'size': '4404'}