# Learn with Ray

DAY 1:

`print("Hello")print('how are you today?')print(5+4)print('5+4')print('5+4=',5+4,'and 6+4=',6+4)var_1 = 5 #datatype is implicitprint(var_1+10)#variable naming rule: It shouldnt start with a number, only _ is a allowerd special charactervar_1 = 15print(var_1+10)#comments are for human#print() - functions are written to perform certain task#interpreter (Python R) or compiler (C C++ Java...)# 5 basic datatypes:## int - integer - numeric values without decimal part:  -999, -99, 0,1,2,99## float - float - numeric values with decimal part:  -5.5, 5.0, 0.0## complex - complex - numeric values that represent square root of minus 1 (i)## str - string - text data## bool - boolean - just two values:  True / Falsevar_1 = 5jprint(var_1 * var_1) #25*-1= -25print(type(var_1))#operators & operation#Arithmetic operators:  +  -  *  /   // (integer division)  ** % (modulus - mod)num1 = 7num2 = 3print(num1/num2)print(50 // 6)print(num1 ** num2)print(50 % 6)#Comparison operators: ==  >  >=  <  <=  !=  Will always result in bool valuesnum1 = 10num2 = 10num3 = 15print(num1 == num2) #is num1 equal to num2 ? Trueprint(num1 != num3) #is num1 not equal to num2? Trueprint(num1 > num2) # Falseprint(num1 >= num2)  #Trueprint(num1 < num2) # Falseprint(num1 <= num2)  #True#Logical operators = and / or = they work only on boolean value and given bool as result#prediction1: Argentina and France will play in the Soccar world cup final - True#prediction2: Argentina or Brazil will play in the Soccar world cup final- True#actual: Argentina and France actually played in the finals#and truth table:# True and True = True# False and False = False and True = True and False = False#or truth table:# False or False = False# True or True= False or True = True or False = Truea,b,c=5,       10,10print(a > b and b<c and c==a or c==b or a>c and c<a and b==b and c<a or c==b)#Conditions# I want to check if a number is positive or notnum1 = 0if num1 >0:       print("Number is positive")       print("Line 2 for positive")elif num1<0:    print("Number is negative")    print("Line 2 for negative")else:    print("Number is neither positive nor negative")print("Thank you")`

## Day 1: Watch The Video Here

`#conditions#if - elif - else#### When +ve: case 1 = 3 , case 2 =3# When -ve: case 1 = 3 , case 2 =2# When 0: case 1 = 3 , case 2 = 1##num = -50#case 1if num==0:    print("Its Zero")if num <0:    print("Its negative")if num >0:    print("Its positive")#case 2if num==0:    print("Its Zero")elif num <0:    print("Its negative")else:    print("Its positive")#converting one datatype to another - str(), int(),float(),complex(),bool()marks_in_subject1 = int(input("Enter marks in Subject 1:"))print(type(marks_in_subject1))marks_in_subject2 = 8.0marks_in_subject3 = 88marks_in_subject4 = 8marks_in_subject5 = 8total = marks_in_subject1 + marks_in_subject2 + marks_in_subject3+marks_in_subject4+marks_in_subject5avg = total/5print("Average = ",avg)#avg > 85 - A# avg>70 - B# avg > 60 - C#avg >50 - D#avg >40 - E#avg < 40 - F#avg >=90 - special awardif avg >=85:    print("You got grade A")    if avg>=90:        print("You win Special award")        if avg>=95:            print("You get a Scholarship")elif avg >=70:    print("You got grade B")elif avg>=60:    print("You got grade C")elif avg>=50:    print("You got grade D")elif avg>=40:    print("You got grade E")else:    print("You got grade F")print("Thank You")#nested#LOOPS - Repeatprint("Hello")# Loops - For loop and While loop#For loop is used when you know how many times you need to repeat#While loop is used when you dont know exactly how many times but you know the condition#when to stop#print hello 5 times# range(a,b,c) : a=start (inclusive), b = end (exclusive), c=increment# range(2,8,3) : 2,5# range(a,b) : a=start, b=end, default increment = 1# range(2,5) : 2,3,4# range(b): default start = 0, end=b, default increment of 1# range(5): 0,1,2,3,4print("For loop 1:")for var in range(5):    #print("Value of var is ",var)    print("Hello")print("Using while: ")counter = 1while counter <=5:    counter = counter + 1    print("Hello")print("Thank You")`

## Day 2: Watch the video here

DAY 3:

`#Day 3: Loops#For loop - along with range() , how many times the loop has to runfor i in range(1,101):    print(i,end="\t")print()print("Hello")#by default print will give us a newlinen,m=5,6for j in range(m):    for i in range(n):        print("*",end=" ")    print()'''* * * * * * * * * * * * * * * * * * * * * * * * * '''n=5for j in range(n):    for i in range(j+1):        print("*",end=" ")    print()'''*  * *  * * *  * * * *  * * * * * '''n=5for j in range(n):    for i in range(n-j):        print("*",end=" ")    print()'''* * * * * * * * * * * * * **'''print("-----")for j in range(n):    for k in range(n-j-1):        print(" ",end="")    for i in range(j+1):        print("*",end=" ")    print()'''    *     * *    * * *   * * * *  * * * * * '''# check if a number is prime or notnumber = 51# 51 - 1, 51isPrime = Truefor i in range(2,number//2):    if number%i==0:        isPrime=False        break        #break will throw you out of current loopif isPrime:    print("Number is prime")else:    print("Number is not Prime")total = 0for i in range(1,101):    total=total+iprint("\n total is ",total)#1: total= 0 + 1 = 1#2: total = 1 + 2 = 3#3: total = 3 + 3 = 6#Whilewhile True:    print("Hello")    if True:        breakimport randomrandom.seed(10)num = random.random() #generates random number between 0 and 1print("num = ",num)num1 = random.randint(1,10)  # integer values - between 1 and 10 (both inclusive)print("num1 = ",num1)attempts = 0actual = 45 #random.randint(1,100)while True:    guess = int(input("Enter your guess number:"))    attempts=attempts+1    if actual == guess:        print(f"Congratulations! You have guessed it correctly in {attempts} attempts")        break    elif actual < guess:        print("You missed it! Your Guess is higher")    else: #actual >guess        print("You missed it! Your Guess is lower")`

## DAY 3: Video

`#Stringsvar1 = 'hello'print(type(var1))var2 = "good morning"print(type(var2))var3 = '''Hi therewhere are you goingI am here till you come'''print(type(var3))var4 ="""Hows goingI was waiting to talk to yousee you soon"""print(type(var4))print(var3)print(var4)# What's your name?var5 = "What's your name?"print(var5)# He asked,"How are you"?print('He asked,"How are you"?')# He asked,"What's your name"?print('''He asked,"What's your name"?''')print("He asked,\"What\'s your name\"?")var1 = 'hello'print('H' in var1)for i in var1:    print(i)#  'y'  'a'  "yes" "no"  "name"# ' or " can only take one line of text#''' or """ can take multi line text# [] square brackets are used for indexingprint("=====> 1. ",var1[4])print("=====> 1. ",var1[-1])print("=====> 2. ",var1[0:4])print("=====> 3. ",var1[:4])print("=====> 3. ",var1[-5:-1])print("=====> 3. ",var1[:-1])print("=====> 4. ",var1[-3:])#len()print("Length = ",len(var1))for i in range(len(var1)):    print(var1[i])var1 = "hello"var2 = "Good Morning"print(var1,var2)print(var1 + " and "+(var2+ " ")*3)`

## DAY 4 Video - WHILE LOOP and STRINGS Intro

`#Stringsstr1 = "hellothere"  #str1 is an object of class strstr2 = "49534095834"print("str2.isdigit(): ",str2.isdigit())print("str1.isdigit(): ",str1.isdigit())print("str1.isalpha()",str1.isalpha())print(" ".isspace())str1.isalnum()str1 = "hello there 123"print("str1.islower():  ",str1.islower())str1.isupper()str1.istitle()ch=input("Enter Y to continue: ")#username - username can have only alphabet and/or number#first name -  ABC XYZ#methods (function in a class) v functions -independentnum1 = input("Enter a number: ")if num1.isdigit():    num1=int(num1)else:    print("You have not entered a valid number hence setting num1 to zero")    num1 = 0print("num1 = ",num1)# Exception Handling - to handle runtime errors - preferredstr1 = "HELLO"#strings are immutableprint(str1[0])#str1[0] = "K"  #TypeError: 'str' object does not support item assignment#str1 = "KELLO"str1 = "K"+str1[1:]print(str1)str2="How are YOU? your Where are you? you are welcome"str3 = str2.lower().replace("you","they",2) #old,new,countprint("After Replace: ",str3)print("you" in str2)print(str2.lower().find("you",9))  #find: substring, start, endvar1 = str2.split("o")print(var1)str5 = "o".join(var1)print(str5)#abc => abcing#abing = abinglyinp_txt = input("Enter the word: ")output=""if inp_txt[-3:].lower()=="ing":    output= inp_txt+"ly"else:    output = inp_txt+"ing"print("Output text is",output)str1 = "How are you doing today and whats plan for tomorrow"l_str = ""curr_str = ""inx = 0for c in str1:    inx+=1    if inx==len(str1):        curr_str = curr_str + c    if c.isspace() or inx==len(str1):        if len(curr_str) > len(l_str):            l_str=curr_str        curr_str=""    else:        curr_str=curr_str+cprint("Largest text is",l_str)`