##### Learning with P
`print('hello')print(5 +3  )print('5+3=',   5+3)var1 = 53print(type(var1))  #<class 'int'>  integervar1 = '53'  # str - stringprint(type(var1))var1 = 53.0  #floatprint(type(var1))var1 = 53j   #complexprint(type(var1))var1 = False  #print(type(var1))count_of_pens = 23  #variable names can only have alphabets, numbers, _#variable shouldnt begin with a numbercost_each_pen = 21.23total_cost = cost_each_pen \             * count_of_pensprint('Cost of each pen is',cost_each_pen,"so for",count_of_pens,"pens, "       "total cost would be",total_cost)#f-string format stringprint(f"Cost of each pen is {cost_each_pen} so for {count_of_pens} pens, total cost would be {total_cost:.1f}")`

## VIDEO 1

`###################player= "Rohit"country = "India"position = "Captain"print(f"The Player {player:<15} plays for the country {country:^15} and is {position:>15} of the team")player= "Mbangawapo"country = "Zimbabwe"position = "Wicketkeeper"print(f"The Player {player:<15} plays for the country {country:^15} and is {position:>15} of the team")num1 = 5num2 = 3#Arithematic Operationsprint(num1 + num2)print(num1 - num2)print(num1 * num2)print(num1 / num2)  #float outputprint(num1 // num2) #integer division (double division)- integer (int)print(num1 % num2)  #remainder - moduloprint(num1 ** num2)  #num1 to the power num2#post office stamp problem for assignmentlength = input("Enter length of the rectangle: ")length = int(length)print(type(length))breadth = int(input("Enter breadth of the rectangle: "))area = length * breadthperimeter = 2*(length + breadth)print(f"The rectangle with length {length} and bread {breadth} has an area of {area} and perimeter of {perimeter}")#Comparison operators:  <   >    <=   >=  ==   !=#input here is variables, output is always bool valueval1=34val2=34print("Is val1 less than val2? ", val1 < val2)print("Is val1 greater than val2? ", val1 > val2)print("Is val1 less than or equal to val2? ", val1 <= val2)print("Is val1 greater than or equal to val2? ", val1 >= val2)print("Is val1 equal to val2? ", val1 == val2)print("Is val1 not equal to val2? ", val1 != val2)#Logical operators: and or not: Input is bool and output is also boolprint(val1 < val2 and val1 > val2 or val1 <= val2 and val1 >= val2 and val1 == val2 or val1 != val2)#in AND - even if you have one false - o/p is False otherwise True# in OR - even if you have one True - o/p is True otherwise Falseprint(not val1==val2)#membership operator: in, not inprint( 5 in [5,10,15,20])print("a" not in "ABCDE")marks1 = int(input("Enter the marks in subject 1: "))marks2 = int(input("Enter the marks in subject 2: "))marks3 = int(input("Enter the marks in subject 3: "))total = marks1 + marks2 + marks3avg = total / 3print(f"Total marks obtained is {total} and the average is {avg:.2f}")`

`#Conditionalnum1 = -90if num1 >0:    print("Number is positive")    print("This is second line of if")if num1 >0:    print("Number is positive")else:    print("Number is not positive")if num1 >0:    print("Number is positive")elif num1 <0:    print("Number is negative")else:    print("Its Zero")avg = 80'''avg >= 90: Grade A, 80-90: B, 70-80: C, 60-70: D, 50-60:E, 40-50: F and Grade Failed <40'''if avg>=90:    print("Grade: A")elif avg>=80:    print("Grade: B")elif avg>=70:    print("Grade: C")elif avg>=60:    print("Grade: D")elif avg>=50:    print("Grade: E")elif avg>=40:    print("Grade: F")else:    print("Grade: FAILED")if avg>=40:    print("You have passed")#print - You have passed for all those who got over 40%avg=99.1if avg>=40:    print("You have passed")    if avg >= 90:        print("Grade: A")        if avg >=95:            print("You win President's medal")            if avg>=99:                print("WOW")    elif avg >= 80:        print("Grade: B")    elif avg >= 70:        print("Grade: C")    elif avg >= 60:        print("Grade: D")    elif avg >= 50:        print("Grade: E")    else:        print("Grade: F")else:    print("Grade: FAILED")#to evaluate an algorithm - we look at Space complexity and Time complexity# President medal for >95%num1 = 78if num1%2==0:    print("Even")else:    print("Odd")age=21nationality = "USA"if age>21 and nationality=="USA":    print("Vote")####### LOOPS -  repeatition# for loop: exactly how manytimes to run the loop# while loop: condition under which to repeat the loop# range(a,b,c): a= initial value (including), b=end value (excluding), c= increment#range(3,12,3): 3,6,9#range(3,13,3): 3,6,9,12for i in range(3,16,3):    print("HELLO")    print("i = ",i)`

## Video 3 Here

`for i in range(5):    print("*",end=' ')print()'''* * * * * * * * * * * * * * * * * * * * * * * * * '''for j in range(5):    for i in range(5):        print("*",end=' ')    print()'''* * *  * * *  * * * *  * * * * * '''for j in range(5):    for i in range(j+1):        print("*",end=' ')    print()'''* * * * ** * * ** * * * * * '''for j in range(5):    for i in range(5-j):        print("*",end=' ')    print()'''    *    * *    * * *   * * * *  * * * * * '''for j in range(5):    for i in range(5-j-1):        print(" ",end='')    for k in range(j+1):        print("*",end=' ')    print()n=5m=1for j in range(1,11):    for i in range(1,11):        print(f"{i:>2} * {j:>2} = {j*i:>3}",end="  ")    print()#### WHILE Loops: no fixed times - based on some conditioni=1while i<=10:    print(i)    i+=1#print hello untill user wantsch='y'while ch=='y':    print("HELLO")    ch=input("Press y to continue, anyother key to stop: ")`

## DAY 4 Video

`import randomnum = random.randint(1,100)print("==> ",num)l1="="total_attempts,max,min=0,0,9999n=250000pc = n//100for i in range(n):    attempt = 0    while True:        guess = int(input("Guess the number: "))        #guess = random.randint(1,100)        attempt +=1  # attempt = attempt + 1        if guess ==num:            print(f"Congratulations! You have guessed it correctly in {attempt} attempts.")            total_attempts +=attempt            if min > attempt:                min = attempt            if max < attempt:                max = attempt            if i%pc==0:                print(i//pc,"% Completed")            break        elif guess > num:            print("Sorry, Actual number is smaller")        else:  #guess < num:            #pass            print("Sorry, Actual number is greater")print("Average number of attempts it took: ",total_attempts/n)print("Maximum attempt:",max," and minimum attempt:",min)##################################  Attempt  2  ##import random#print("==> ",num)l1="="total_attempts,max,min=0,0,9999n=250000pc = n//100num = random.randint(1, 100)for i in range(n):    attempt = 0    start, end = 1, 100    while True:        #guess = int(input("Guess the number: "))        guess = random.randint(start,end)        if guess>100 or guess <1:            continue  #takes you to the beginning of the loop        attempt +=1  # attempt = attempt + 1        if guess ==num:            #print(f"Congratulations! You have guessed it correctly in {attempt} attempts.")            total_attempts +=attempt            if min > attempt:                min = attempt            if max < attempt:                max = attempt            if i%pc==0:                print(i//pc,"% Completed")            break        elif guess > num:            #print("Sorry, Actual number is smaller")            end=guess-1        else:  #guess < num:            #pass            #print("Sorry, Actual number is greater")            start =guess+1print("Average number of attempts it took: ",total_attempts/n)print("Maximum attempt:",max," and minimum attempt:",min)`

## DAY 5 VIDEO (While Example)

`#Stringsstr1 = 'Hello'str2 = "How are you?"str3 = """I am fineI am greatI am amazing"""str4 = '''I am here'''print(str3)print("What's your name?")print('What\'s your name?')print(str1 + " "+str2)print(str1 *5)for i in str1:    print("Hello")#subset of the stringstr6 = "What's your name?"print(str6[0])print(str6[2])print(len(str6))print(str6[len(str6) - 1])  #last charprint(str6[len(str6) - 2])  #2nd last charprint(str6[- 1])  #last charprint(str6[- 2])  #2nd last charprint(str6[-len(str6)])print(str6[:3])print(str6[-3:])### Methodsprint(str6.index("W"))`

## Video Day 6

`str1 = 'How are YOU I AM fine'#they are immutable - you cant edit them#str1[0] = 'h'  #TypeError: 'str' object does not support item assignmentstr1 = 'h'+str1[1:]print(str1)#functions are independent - print(), len(), input(), int(), str()#methods - they are functions written within a classprint(str1.isdigit())val1 = str(5)#input("Enter a number: ")if val1.isdigit():    val1  = int(val1)else:    print("Invalid number! setting val1 to zero")    val1 = 0print(val1)str2="Hello123"print(str2.isalnum())print(str1.upper())  #isupper()print(str1.lower())print(str1.title())print(str1)print(str1.split("o"))  #default split is done on blank spacel1 = str1.split()str2 = "|| ||".join(l1)print(str2)str3 = "Ioooamooofineooohowoooareoooyouooo?"str4 = " ".join(str3.split("ooo"))print(str4)occ = str3.find("ooo")print("Occurences = ",occ)occ = str3.count("ooo")print("Occurences = ",occ)start,end=0,len(str3)for i in range(occ):    po = str3.index('ooo',start,end)    print(po,end=" , ")    start = po+1print()# LISTl1 = []print(type(l1))print(len(l1))l1 = [4,"Hello",8.0,True,[2,4,5],"Fine"]print(type(l1))print(len(l1))print(len(l1[4]))print(l1[4][1])#list is mutable (unlike str)l1[0]= 444print(l1)print(l1+l1)print(l1 *3)for i in l1[4]:    print(i)#list methods`

### Video for Class 7 here

`#Tuple - immutable version listt1 = (2,2,4,6,8,10)  #packinga,b,c,d,e,f = t1#print(a,b,c,d,e,f)print(type(t1))print(len(t1))for i in t1:    print(i," - ",t1)print(t1[-2:])#t1[2] = 88print(t1.index(8))print(t1.count(2))t1= list(t1)t1.append(18)t1=tuple(t1)a=(5,88,1,77,99)b=(5,88,1,77,99)if a>b:    print(a)elif b>a:    print(b)else:    print("both are same")# List - linear ordered collectionl1=[4,6,8,10,12,8,10,12,8,0,8]l1.append(55)  #add element at the endprint(l1)l1.insert(3,90)l1.insert(3,70)print("2. ",l1)#element = 12if element in l1:    l1.remove(12)else:    print("Element doesnt exist")if l1.count(element)<1:    print("Element doesnt exist")print()print("3. ",l1)l1.pop(3)print("4. ",l1)print(l1.index(8))s,e=0,len(l1)for i in range(l1.count(8)):    inx = l1.index(8,s,e)    print(inx,end=", ")    s=inx+1print()print("5. ",l1)#copyl2 = l1  #deep copy - (giving another name)l3 = l1.copy()  #shallow copy (photocopy)print("After copy")print("L1 = ",l1)print("L2 = ",l2)print("L3 = ",l3)l1.append(101)l2.append(102)l3.append(103)print("After editing")print("L1 = ",l1)print("L2 = ",l2)print("L3 = ",l3)l1.reverse()print("Reverse: ",l1)l1.sort()print("Sort: ",l1)l1.sort(reverse=True)print("Sort R: ",l1)#stack - LIFO: add using append, remove: pop(-1)#queue - FIFO: append, pop(0)# 1,5,8,9,7#add 5 numbers from the usersum=0nums=[]for i in range(5):    num = int(input("Enter the number: "))    sum+=num    nums.append(num)print("Sum is ",sum)print("Printing values: ",nums)`

## VIDEO CLASS 8

`#  [[a,b,c],[x,y,z],[p,q,r]]master_list = []for i in range(3):    temp=[]    for j in range(3):        m=int(input("Enter the marks: "))        temp.append(m)    master_list.append(temp)print("Master list: \n",master_list)'''Assignment: Exten the above program to find highest marks for each subject and foreach students. Eg if the marks are: [[66, 77, 88], [98, 87, 76], [45, 65, 76]]Highest for subject 1 = 98                    2 = 87                    3 = 88Highest for Student 1 = 88                    2 = 98                    3 = 76'''# Dictionary - key:valuedict1 = {:,:, :,:}printtype(dict1[])print"Hello""Hola"(dict1)#deep copy#shallow copy(dict1.keys())print(dict1.items())i dict1.keys():    (i, dict1[i])a,b dict1.items():    (a,b)k dict1.items():    (k)stats = {:[,,,],:[,,,],:[,,,]}for in if "Virat"printdict3.pop()print`

## VIDEO CLASS 9

`#Sets#data structures - collections: String, List, Tuple, Dictionary#SETS - A B M O C - there is no order# doesnt allow duplicateset1 = {2,4,6,8}print(set1)#union intersection minusset2 = {6,8,10,12}#unionprint(set1.union(set2))print(set1 | set2)#intersectionprint(set1.intersection(set2))print(set1 & set2)#differenceprint(set1.difference(set2))print(set1 - set2)print(set2.difference(set1))print(set2 - set1)#symmetric difference#union of 2 differencesprint(set1.symmetric_difference(set2))print(set1 ^ set2)print(set1, set2)#update doesnt give new set, it changes the main setset1.update(set2)#union -> update# {intersection_update, difference_update, symm_diff_update}print(set1, set2)set3 = {2,4,10,12}# sets to list and to tupleset1 = tuple(set1)list(set1)set()`