# Python program to check if a string is # palindrome or not # function to check palindrome string def isPalindrome(string): rev_string = string[::-1] return string == rev_string # Main code x = "Google" if isPalindrome(x): print(x,"is a palindrome string") else: print(x,"is...
Similar to the previous example, this Python program begins by obtaining a string input from the user using theinput()function. The pivotal lines of code are: ifstr(word)=="".join(reversed(word)):print("Palindrome") Here, the predefined function"".join(reversed(word))is used, wherereverse...
# Program to check if a string is palindrome or not my_str = 'aIbohPhoBiA' # make it suitable for caseless comparison my_str = my_str.casefold() # reverse the string rev_str = reversed(my_str) # check if the string is equal to its reverse if list(my_str) == list(rev_str):...
# variablesa=100# an integer variableb=10.23# a float variablec='A'# a character variabled='Hello'# a string variablee="Hello"# a string variable# checking typesiftype(a)==str:print("Variable\'a\'is a type of string.")else:print("Variable\'a\'is not a type of string.")iftype...
Python allows user to pass command from out of a python file.See here The resu...Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer to string, note the ...
11. Check if a Number is PerfectWrite a Python function to check whether a number is "Perfect" or not.According to Wikipedia : In number theory, a perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors ...
Learn how to check if a given number is a perfect number in Java with this simple guide and example code.
Here is source code of the Python Program to check whether a string is a palindrome or not using recursion. The program output is also shown below. defis_palindrome(s):iflen(s)<1:returnTrueelse:ifs[0]==s[-1]:returnis_palindrome(s[1:-1])else:returnFalsea=str(input("Enter string:...
How to convert String to Integer SQL and Database?... What is Normalization in SQL? 1NF, 2nd NF, 3rd NF... What is temporary table in Database and SQL? Examp... How to use EXISTS and NOT EXISTS in SQL? Microsoft... Top 21 Web Development Interview Questions with An... ...
Java Program to Check Whether a Number is Positive or Negative - In this article, we will learn to check whether the number is positive or negative in Java. To check whether the specified number is positive or negative can be determined with respect to 0