Added functions to check for palindromes and convert nums to bin strings

This commit is contained in:
2021-06-29 15:22:37 -04:00
parent 0bbb7ff9bf
commit 6ed905fa01
2 changed files with 51 additions and 2 deletions

View File

@@ -236,3 +236,16 @@ def factorial(num: int) -> int:
for cnt in range(1, num + 1):
fact *= cnt
return fact
#Returns true if the string passed in is a palindrome
def isPalindrome(str: str) -> bool:
rev = str[::-1]
if(str == rev):
return True
else:
return False
#Converts a number to its binary equivalent
def toBin(num: int) -> str:
#Convert the number to a binary string
return "{0:b}".format(num)