Posts

Showing posts with the label While Loop

Python Loops - While Loop

Image
  With the   while loop   we can execute a set of statements as long as a condition is true. while expression:     statement(s) Example: A program that adds number up to num where num is entered by the user.          The total = 1+2+3+4… up to the supplied number. Program:  Generate the following sequences using while loop: Even Numbers Between 50 and 75 Numbers between 1 and 100 in reverse order that are divisible by 5 #A) Even Numbers Between 50 and 75 a= 50 print ( "Even Numbers Between 50 and 75 is" ) while(a<= 75 ):      if  (a% 2 == 0 ):           print (a,end= ' ' )     a+= 1 Output: Even Numbers Between 50 and 75 is 50 52 54 56 58 60 62 64 66 68 70 72 74 #B) Numbers between 1 and 100 in reverse order that are d...