x = 5 if x > 3: print("x is greater than 3") else: print("x is not greater than 3")
for i in range(3): print(i)
x=5 while x<10: print(x, end="")
n=7 c=0 while(n): if(n>5): c=c+n-1 n=n-1 else: break print(n) print(c)
while(7): if(n>5): true c= c+n-1 = 0+7-1 = 6 n= n-1 = 7-1 = 6 now n= 6 value goes to while. while(6): if(n>5): true c= c+n-1 = 6+6-1 = 11 n= n-1 = 6-1 = 5 now n= 5 value goes to while. while(5) else: break it will be stop. print latest value of n and c which is 5 , 11
str1="desktop" c=0 for x in str1: if(x!="o"): c=c+1 else: pass print(c)
for x in str1 : means x in 'desktop' - it is range for x if (x!="o") which is true x = 'd' c=0+1 =1 Now x='e' c=1+1 = 2 when x='0' else condtion is use which is pass it simply pass to next Now, x="p" c= 5+1 = 6 range of x complete print (c) which is c=6
a=0 b=1 while(b<8): print(b) a,b=b,a+b