INFINITE LOOPS ============== LOOP ==> ITERATION UNTIL THE CONDITION IS True, THE BLOCK OF CODE ==> EXECUTE REPEATEDLY INFINITE LOOPS ==> THE LOOP BODY, WILL EXECUTE FOR NUMBER OF TIMES ==> KEYBAORD INTERRUPT ===> CTRL + C REASONS: 1) WHEN THE CONDITION IS INCORRECT 2) WHEN THE UPDATE IS INCORRECT 3) WHEN THE UPDATE IS MISSING APPLICATIONS: ============ 1) SERVER-CLIENT MODEL ==> PROTOCOLS (TELECOM, NETWORK) 2) GAMING APPLICATION DEVELOPMENT ====================================== TRANSFER CONTROL STATEMENTS ============================== ==> ALSO CALLED AS "LOOP CONTROL STATEMENTS" 1) WHEN WE WANT STOP EXECUTING THE BLOCK OF CODE UNCERTAINLY (UNEXPECTEDLY) EX: 1 TO 10 1 2 3 4 5 6 ==> STOP 2) WHEN WE WANT TO PAUSE THE EXECUTION OF BLOCK OF CODE AND MAKE CONTINUE WITH THE REMAINING EX: 1 TO 10 1 2 3 4 5 6 ==> NOT 7 8 9 10 ==> TWO TYPES: 1) break statement 2) continue statement 1) break statement =============== here: break ===> keyword Syntax: break we can always define the break inside the loops only along with condition. ==> to stop executing the block of code immediately for i in range(1,11): if i == 6: break print(i,end = "\t") ====================== 2) continue statement ================= here: continue ==> keyword Syntax: continue we can always use the continue in loops only along with condition ==> when we want to pause the iteration and continue with remaining str_data = "Python" for i in str_data: if i == 'h': continue print(i) i = 100 while i >= 1: if i % 7 == 0: break print(i,end = "\t") i -= 1 i = 100 while i >= 1: if i % 7 == 0: i -= 1 continue print(i,end = "\t") i -= 1 ================================ Pattern Printing ============ ==> we should be aware of nested loops lines = int(input("Enter number of rows:")) # row wise operation for row in range(1,lines+1): # column wise operation for col in range(1,row+1): print("* ",end = "") print() lines = int(input("Enter number of rows:")) # row wise operation for row in range(1,lines+1): # column wise operation for col in range(1,row+1): print(row,end = " ") print() lines = int(input("Enter number of rows:")) # row wise operation for row in range(1,lines+1): # column wise operation for col in range(1,row+1): print(col,end = " ") print() chr() ==== ==> return a character by taking/accepting an ASCII value. Syntax: chr(ascii_value) lines = int(input("Enter number of rows:")) value = 97 # ascii of lower case alphabet for row in range(1,lines+1): for col in range(1,row + 1): alpha = chr(value) print(alpha,end = " ") value += 1 print() 256 characters ==> 0 to 255 digits ==> 0 to 9 ==> Ascii values ==> 48 to 56 alphabets lower case ==> 97 to 122 upper case ==> 65 to 90 special characters