Untitled

 avatar
unknown
plain_text
a year ago
894 B
8
Indexable
# lab 1
def palindrome (str):
    cpy=str[::-1]
    if (str==cpy):
        return True
    else:
        return False

str = input("Enter the string you wanna check : ")
print(f"Is the string palindrome ?\nAns : {palindrome(str)}")



# lab 2
def is_power_of(a,b):
    while(a%b==0):
        a/=b
    
    if(a==1):
        return True
    else:
        return False


a = int(input("Enter the value of a : "))
b = int(input("Enter the value of b : "))
print(f"b is the power of a ?\nAns : {is_power_of(a,b)}")


# lab3
def los(str):
    length=0
    for _ in str:
        length+=1

    return length

str1 = input("Enter the string you wanna find the length : ")
print(f"Length is the string is -> {los(str1)}")

str2 = input("\nEnter the string you want to concatinate : ")
str3 = str1 + str2

print(f"Final string is {str3}\n\nThe length of the right most string is {los(str3)-los(str1)}")
Editor is loading...
Leave a Comment