Find Factorial using while Loop
print("Enter the Number: ")
num = int(input()) fact = 1 i = 1 while i<=num: fact = fact*i i = i+1 print("\n Factorial =", fact)
Check Leap Year in python
print("Enter the Year: ") y = int(input()) if y%4==0 and y%100!=0: print("\nIt is a Leap Year") elif y%400==0: print("\n It is a Leap Year") else: print("\n It is not a Leap Year")Check Reverse Equals Original in Python
print("Enter the Number: ") num = int(input()) rev = 0 orig = num while num>0: rem = num%10 rev = rem + (rev*10) num = int(num/10) if orig==rev: print("\n The Number is Equal to Its Reverse") else: print("\n The Number is not Equal to Its Reverse")Check Palindrome Number in Python
print("Enter the Number: ") num = int(input()) rev = 0 temp = num while temp>0: rem = temp%10 rev = rem + (rev*10) temp = int(temp/10) if rev==num: print("\n It is a Palindrome Number") else: print("\n It is not a Palindrome Number")
No comments:
Post a Comment