mirror of
https://bitbucket.org/Mattrixwv/pyclasses.git
synced 2025-12-06 18:33:58 -05:00
Added functions to check for palindromes and convert nums to bin strings
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user