Loop Statements: ================ -> also called as "Iterative Statements". when we can use? ================ when we want execute the block of code more than one time continuously, then we can use "loop statements". Ex: Hi for 5 times 1. print("Hi") 2. print("Hi") 3. print("Hi") 4. print("Hi") 5. print("Hi") -> we have two types of loop statements: 1) while loop 2) for loop -> loop statements can work on three things: 1) Initialization ==> describe the start of the loop 2) Condition ==> until which the loop can execute 3) Update ==> can be increment/decrement to traverse from start to end step by step 1) while loop: ============== Syntax: initialization for while loop while condition: statements (while loop body) update next statement Note: ==== If update statement is absent in while loop body, the loop can be infinite. # WAP TO PRINT HELLO FOR 10 TIMES USING WHILE LOOP line = 1 # initialization while line <= 10: # condition print("Hello") line = line + 1 # update print("Loop Operation was stopped because line has reached a value of 11.") print(line) ====================================================== # WAP TO PRINT THE NUMBER OF DIGITS OF A GIVEN NUMBER. number = int(input("Enter a number:")) # 987654 countDigits = 0 n = number # initilization while n > 0: # condition indDigits = n % 10 countDigits = countDigits + 1 n = n // 10 # update print("The number of digits of",number,"is = ",countDigits) ===================================================== # WAP TO PRINT THE REVERSE OF THE GIVEN NUMBER. number = int(input("Enter a number:")) n = number # initialization reverseNumber = 0 while n > 0: # condition digits = n % 10 reverseNumber = reverseNumber * 10 + digits n = n // 10 # update print("The Reverse of",number,"is = ",reverseNumber) Assignment: =========== WAP TO FIND THE SUM OF DIGITS OF A GIVEN NUMBER. 98765 ==> 9 + 8 + 7 + 6 + 5 ==> 35