Posts

Palindrome String using Recursion (Easy method)

 def palindrome(s,n,r):     if n==0:         return r      else:         r+=s[n-1]         return palindrome(s,n-1,r) s="malayalam" n=len(s) r='' res=palindrome(s,n,r) if s==res:     print(res,"is palindrome string") else:     print(res,"is not palindrome string")

Palindrome number using recursion

  def palindrome(n,r):     if n==0:         return r     else:         r=n%10+r*10         return palindrome(n//10,r) n=1001 r=0 res=palindrome(n,r) if n==res:     print(res,"is palindrome") else:     print(res,"is not palindrome")

print all prime number from 1 to 100

  for n in range(2,101):     t=0     for i in range(2,n):         if n%i==0:             t=1             break     if t==0:         print(n,end=" ")

Fibonacci series in python using function

 def fib(n):     if n==0:         return 0     elif n==1:         return 1      else:         return fib(n-1) + fib(n-2) n=int(input()) for i in range(n):     print(fib(i),end=" ")

Fibonacci Series in python

a=0 b=1 print(a,b,end=" ") for i in range(10):     c=a+b      a=b      b=c     print(c,end=" ")

2D Array - DS solution

Image
  Given a     2D Array ,   : 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 An hourglass in   is a subset of values with indices falling in this pattern in  's graphical representation: a b c d e f g There are   hourglasses in  . An  hourglass sum  is the sum of an hourglass' values. Calculate the hourglass sum for every hourglass in  , then print the  maximum  hourglass sum. The array will always be  . Example -9 -9 -9 1 1 1 0 -9 0 4 3 2 -9 -9 -9 1 2 3 0 0 8 6 6 0 0 0 0 -2 0 0 0 0 1 2 4 0 The   hourglass sums are: -63, -34, -9, 12, -10, 0, 28, 23, -27, -11, -2, 10, 9, 17, 25, 18 The highest hourglass sum is   from the hourglass beginning at row  , column  : 0 4 3 1 8 6 6 Note:  If you have already solved the Java domain's  Java 2D Array  challenge, you may wish to skip this challenge. Function Description Comp...

Library Management System in python OOPs Concept

Image
 class Library:     def__init__(self,listofbooks,libraryname):         self.lst = listofbooks         self.name = libraryname     def displaybook(self):         return f"\t\t\t\tWelcome to {self.name} \         \navaliable books are -\n {self.lst}"     def lendbook(self,lendname,bookname):         if bookname in lst and bookname not in d:             print(f"{bookname} lend to {lendname}")             d.__setitem__(bookname,lendname)         elif bookname in d:             lst.remove(bookname)             print("Book is not available lend to-",d[bookname],"\nwe only have-",lst)         else:             print("Book is not in the library we only have-",lst)   ...