Monday, August 15, 2022

### Python program to check whether a string is a palindrome or not

string=input("Please enter a string: ") if(string==string): print("Given string is palindrome") else: print("Given string is not palindrome") ...

### Python program to count the number of vowels in a string

string=input("Please enter string: ") vowels=0 for i in string: if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or =='I' or i=='O'...

### Python program reads a line prints its statistics

line=input("Please enter a line: ") lowercount=uppercount=0 digitcount=alphacount=0 for a in line: if a.islower(): lowercount+=1 ...

### Python program to print the following pattern without using any nested loop

string='#' pattern="" # Empty String for a in range (7): pattern+=string print(pattern) Output: ...

### Python program to read a string and display it in reverse order

str=input("Please Enter a string: ") print("The",str, "in reverse order is:") length=len(str) for a in range(-1,(-length-1),-1): print(str) Output: ...

### Python program to find the GCD of two numbers using recursive

def gcd(x,y):     if(y==0):       return x     else:       return gcd(y,x%y) x=int(input("Please enter first number: ")) y=int(input("Please enter second...

### Python program to check find the given year is a leap year or not

year=int(input("Please enter a year to be check leap year or not: ")) if(year%4==0 and year%100!=0 or year%400==0): print("This year is a leap...

### Python program to find the LCM of two numbers using recursive

def lcm(a,b): lcm.multiple=lcm.multiple+b if((lcm.multiple % a == 0) and (lcm.multiple % b == 0)): ...