## While Loop in Python

``````#----------------------------- 1- Odd or Even in while loop  -------------------------

num1 = int(input("Enter the number : "))
num2 = int(input("Enter the high value : "))
while(num1<=num2):
if(num1 % 2 == 0):
print(num1," is Even number")
num1+=1
else:
print(num1," is Odd number")
num1+=1

``````
``````#----------------------------- 2- Palindrome number in while loop  -------------------

num=int(input("Enter number:"))
n=num
temp=num
rev=0
while(num>0):
pali=num%10
rev=rev*10+pali
num=num//10
if(temp==rev):
print("The number ",n," is a palindrome!")
else:
print("The number ",n," isn't a palindrome!") ``````
``````#----------------------------- 3- Palindrome word in while loop  --------------------

value = int(input("Enter a number of times to check : "))

while (value >0):
letter = input("Enter the word : ")
rev = letter[::-1]  # x[::-1]  is used to reverse the string, x.reverse() can also be used
if letter == rev:
print("The word '",letter,"' is  palindrome.")
else:
print("The word '",letter,"' is not palindrome.",)
value-=1    # decrements value by 1 at every iterate
``````
``````#----------------------------- 4 - Factorial in while loop  --------------------

num = int(input("Enter the number : "))

i = 1
fact=1
while i <= num:

fact = (fact)*(i)
i+=1

print("The factorial of the given number is : ",fact)
``````
``````#----------------------------- 5 - continue, pass, break in while loop  --------------

number = int(input("Enter the number (0 - 12) : "))
string = input("Enter the string : ")
letter =input("Enter the letter to search :")

while  number > 1:
number -= 1
if number in (6,8,5,3) :

continue    # skips the conditons and continue to next iterate, in this it skips the values 6,8,5,3
print(number)

while letter in string:
print("word in list")
break  # breaks and run out of the loop

while(number>78):
pass # having an empty for loop would raise an error without the pass statement``````

## For More Details

Our internship program guarantees personalized attention for optimal career development in the tech industry.

## +91 97879 68375

-> You should bring your own laptop during the internship

Who can apply?

Internships are open for students who: B.E / B.Tech / M.E / M.Tech / B.Sc / M.Sc / M.C.A / B.C.A / Diploma.

• Ongoing Students Only
• days, 5days/ 10days or Based on Student Preference
• Limited 1 to 10 students per slot
• Registration fees : 1000 INR
• Slots are filling quickly only fewer slots are available