##### Learn Data Science

https://youtu.be/mr15WQQoTvI

19 OCTOBER 2022

Day 1 Video Session

`print("hello")print(5+4)print('5+5')print("10+frgjdsijgdskmdklfmdfmv4",5+6," = ",11) `
`# 4 parameters/arguments#Commentprice = 50  #variable called price is assgined a value 50quantity = 23TotalCost = price * quantityprint(TotalCost)`

#The total cost of XquantityX pens selling at XpriceX would be XtotalcostX
print(“The total cost of”,quantity,“pens selling at”,price,“would be”,TotalCost)
print(f”The total cost of {quantity} pens selling at {price} would be {TotalCost}”)

#going to use format string

Session 2: 20 OCT 2022

VIDEO Recording

`var1 = 80var2 = 60sdfdwfdsg = "var3"#Arithematics1 = var1 + var2 print(s1, var1 /var2,"Now minus", var1 - var2)print(var1 - var2)print(var1 * var2)print(var1 / var2) #divisionprint(var1 // var2)  #integer division## Data types: nature of data that we can work#integer : -inf to +inf without decimal#float : decimal -5.0#string: 'hello'#bool (boolean): True / FalseVal1 = True#input()   #take input from the userprint(type(Val1))  #give you the datatype of the variableprice = 50quantity =23totalcost = price * quantitya=50b=23c=a*b`

## VIDEO 3

`#arithematic operators:  + - * / //var1 = 3var2 = 5print(var1 ** var2) #power()print(var1 % var2) #reminder#Relational operators: will always result in bool output (T/F)print("var1 < var2: ",var1 < var2) #is var1 less than var2print(var1 > var2) #is var1 greater than var2print(var1 == var2)print(var1 <= var2) #is var1 less than or equal to var2print(var1 >= var2)print(var1 != var2) #not equal to#Logical operators: will have bool input and bool output# and  or not# F and F = F and T = T and F = FALSE    T and T = Tprint(True and True)print(True and False)#or# T or T = F or T = T or F = True      F or F = Falseprint("True or True: ",True or True)print(True or False)print("Grade  A"   )print("Grade B")print("Grade C")print("Grade D")print("Grade E")print()avg = 40if avg>=50:    print("i am inside if")    print()    sum=5+3    print(sum)print("I am in main")`

Session on 21 OCT 2022

`subject1 = input("Enter the marks in subject 1: ")print(type(subject1))subject1 = int(subject1)print(type(subject1))subject2 = 99subject3 = 100avg_marks = (subject1+subject2+subject3)/3print("Average marks scored is ",avg_marks)if avg_marks >=80:    print("You got grade A")    if avg_marks >=90:        print("You also win President Medal")elif avg_marks >=70:    print("You got grade B")elif avg_marks >=60:    print("You got grade C")elif avg_marks >=50:    print("You got grade D")else:    print("You didnt get grade E")print("Thank You")#Loops - to repeat the steps more than once#1. For : we use it when we know how many times to execute#2. While : we dont know how many times but we know condition till whenfor i in range(10):  #range(10): starts from zero and goes upto 10 (not included 10)    print("Hello")count = 0while count<10:    print("Hello in While")    count=count+1`
`#for loopfor j in range(5):    for i in range(5):        print("*", end=" ")    print()print()# \n - newline#print("A \n B \n C \n D \n E")#print has invisible \n at the endprint("Hello\n")print("Good Morning")`

26 OCT 2022

`#List methodslist1 = [2,4,6,8,10,8,19,8]list1.append(3)  #adds at the end of the listprint(list1)list1.insert(2,14) #(pos,value)print(list1)#remove elements from a list#pop() - removes element at the given positionlist1.pop(1)#remove() - remove given elementlist1.remove(10)print(list1)#index()print("Index: ",list1.index(8))pos=[]c=0for i in list1:    if 8 ==i:        pos.append(c)    c+=1print("Position of 8 in the list: ",pos)list1.pop(pos[-1])list2 = [10,20,30,40]list3 = list1 + list2print(list3)list1.extend(list2)  #list1 = list1 + list2print(list1)list1.reverse() #just reverse the elementsprint(list1)list1.sort() #increasing orderprint(list1)list1.sort(reverse=True) #decreasing orderprint(list1)#list1 = [2, 14, 6, 8, 8, 19, 8, 3]list1 = 4  #we can edit is called MUTABLEprint(list1)list2 = list1  #deep copy: both points to same datalist3 = list1.copy()  #shallow copyprint("1. List1: ",list1)print("1. List2: ",list2)print("1. List3: ",list3)list2.append(22)print("2. List1: ",list1)print("2. List2: ",list2)print("2. List3: ",list3)`

27 OCT 2022

`#linear ordered mutable collection - List#linear ordered immutable collection - Tuplet1 = (1,2,3,4,5)print(type(t1))print(t1[-1])#[] brackets are used for indexing in all datatypes and also list#() - for tuple and also for functionprint(t1)#t1 = 10 - TypeError: 'tuple' object does not support item assignmentprint(t1.index(3))print(t1.count(3))n1,n2,n3 = (2,4,6)  #unpackingprint(n2)for i in t1:    print(i)#comparing: always compares first element and if they are equal# it goes to the next and so on#(2,4) (2,4)print(type(t1))t1 = list(t1)print(type(t1))t1 = tuple(t1)#Dictionary#non-linear unordered mutable collectiond1 = {}print(type(d1))d1 = {"fname":"Sachin", "lname":"Tendulkar","Runs": 130000,"City":"Mumbai"}d1["lname"] = "TENDULKAR"print(d1["lname"])#d1.popitem()print(d1)d1.pop("fname") #removes the value with the given keyprint(d1)#keysprint(d1.keys())for i in d1.keys():    if d1[i] == "TENDULKAR":        print("Remove this key: ",i)print(d1.values())for i in d1.items():    print(i)d1 = {"fname":"Sachin", "lname":"Tendulkar","Runs": 130000,"City":"Mumbai"}d2 = d1d3 = d1.copy()print("1. D1 = ",d1)print("1. D2 = ",d2)print("1. D3 = ",d3)d1.update({"Country":"India"})print("2. D1 = ",d1)print("2. D2 = ",d2)print("3. D3 = ",d3)d3.clear()print(d2)#Sets#linear un-ordered mutable collection - setsset1 = {1,2,3,3,4,3,4,2,1}print(type(set1))print(set1)s1 = {1,2,3,4,5}s2 = {3,4,5,6,7}print(s1|s2)  # Unionprint(s1 & s2)  # Intersectionprint(s1 - s2) #diffprint(s2 - s1)  #diffprint(s1 ^ s2) #symm diffprint(s1.intersection(s2))  #without update will give a new setprint(s1.update(s2)) #update will update the s1 with new valueprint(s1)`

28 OCT 2022

`#Functionsdef mystatements():    print("How are you?")    print("Whats your name?")    print("Where are you going?")print("Hello")mystatements()print("Second")mystatements()def myaddition():    n1 = int(input("Enter number 1 to add: "))    n2 = 50    sum = n1 + n2    print("Addition of two numbers is ",sum)myaddition()num1,num2,num3 = 15,20,25def myaddition2(n1,n3,n2):  #accepting arguments    #n1 = int(input("Enter number 1 to add: "))    n2 = 50    sum = n1 + n2    print("Addition of two numbers is ",sum)myaddition2(num1,num2,num3)  #num1 is the argument we are passing## positional & required##2. positional & defaultdef myaddition2(n1,n2,n3=0):  #accepting arguments    #n1 = int(input("Enter number 1 to add: "))    n2 = 50    sum = n1 + n2    print("Addition of two numbers is ",sum)myaddition2(num1,num2)#3.keyword arguments (not positional)def myaddition2(n1,n2,n3=0):  #accepting arguments    #n1 = int(input("Enter number 1 to add: "))    n2 = 50    sum = n1 + n2    print("Addition of two numbers is ",sum)myaddition2(n3=10,n2=num1,n1=num2)`

SESSION 2

`#4. Function with takes variable number of argumentsdef myownfunction(num1, *numbers, **values):    print("Num 1 is ",num1)    print("Numbers : ",numbers)    print("Values: ", values)    sum=0    for i in numbers:        sum+=i    return sumdef myown2(num1, *numbers, **values):    print("Num 1 is ",num1)    print("Numbers : ",numbers)    print("Values: ", values)    sum=0    for i in numbers:        sum+=iprint("myownfunction: ",myownfunction(3,4,5))print("MyOwn2: ",myown2(3,4,5))out = myown2(3,4,5)print("OUT = ",out)output = myownfunction("Hello",2,4,6,8,10,12,14,16,18,20, name="Sachin",city="Mumbai",runs=25000)print("Output is: ",output)set1= {1,2,3}set2 = {3,4,5}print("Union",set1.union(set2))  #returnprint("Union Update",set1.update(set2)) #doesnt have returnprint("Set1: ",set1)#`
`# Class and Objects#collection of variables and functions (methods) - grouped together to define somethingclass Dog:    num_legs = 4    def __init__(self,name,make):        self.name = name        self.breed = make    def display(self):        print("Name is ",self.name)        print("Breed is ",self.breed)mydog1 = Dog("Tiger","BBB") #object 1 of class Dogmydog2 = Dog("Moti","AAA") #object 2 of class Dog#mydog2.initialize()#mydog1.initialize()print(mydog1.num_legs)print(mydog2.num_legs)mydog1.display()`
`class FourSides:    def __init__(self,a):        self.side1 = a        print('FourSides Object is created')    def _display_4sides(self):        print("Display in 4 Sides")    def area(self):        print("Sorry, I am not complete")    def peri(self):        print("Sorry, I am not complete")class Square(FourSides):    def __init__(self,a):        FourSides.__init__(self,a)        print('Square Object is created')    def area(self):        print("Area is ",self.side1**2)class Rectangle(FourSides):    def __init__(self,a, b):        FourSides.__init__(self, a)        self.side2 = b        print('Rectangle Object is created')    def area(self):        print("Area is ",self.side1*self.side2)sq = Square(10)print(sq.side1)rc = Rectangle(5,10)print(rc.side1)sq.area()`
`#stringvar1 = "Hello"var2 = 'Hello'var1 = '''Hello'''var1 = """Hello"""var1 = """How are youWhere are you doingWhen will you be backTake care"""print(type(var1))print(var1)print(var1[0:3])print(var1[-4:])for i in var2:    print(i)for i in range(len(var2)):    print(var2[i])if "e" in var2:    print("E is in the string")var3 = "i am fine and am doing good"find = var3.find("am",5,19)if find!= -1:    var5 = var3.index("am",5,19)    print(var5)print("  ".isspace())print(var3.islower())print("I Am DoinG Good".istitle())` 