Posts

Python program to toggle Case of string

 x=input("Enter String ") f=len(x) for i in range(0,f):     z=ord(x[i])     if z>=65 and z<91:         print(chr(z+32),end=" ")     elif z>=97 and z<122:         print(chr(z-32),end=" ")

Python program to convert strings to upper and lower cases

#uppercase conversion  n=input("Enter String :") n=n.upper() print(n) #lowercase conversion n=input("Enter String :") n=n.lower() print(n)

Python program to check if strings are same or not

 n=input("Enter String 1:") j=input("Enter String 2:") if n==j:     print("They are same") else:     print("They are Different")

Python program to combine 2 strings

 n=input("Enter String 1:") j=input("Enter String 2:") print("Combined : ",n+j)

Python program to find the length of string

 n=input("Enter String:") j=len(n) print("It's Length : ",j)

Python program to print table of entered number

 n=int(input("Enter N : ")) for i in range(1,11):     print(n," x ",i," = ",n*i)

Python program to find Factorial of Entered Number

 fac=1 n=int(input("Enter N : ")) for i in range(n,0,-1):     fac=fac*i print(n,"! = ",fac)

Python program to find Square root of entered Number

 from math import * n=int(input("Enter N : ")) for i in range(1,n+1):     s=sqrt(i)     print(i,"=",s)

Python program to check if it is a Duck Number or not

 t=r=x=fag=0 n=int(input("ENTER N : ")) while n!=0:     t=n%10     if t==0:        fag+=1     n=n//10 if fag>0:     print("It's a Duck Number") else:     print("It's not a Duck Number")

Python program to print N prime numbers

 count=1 ex=3 n=int(input("ENTER N : ")) print(2) while count!=n:     tmp=0     for i in range(2,ex):         if ex%i==0:             tmp+=1     if tmp==0:         count+=1         print(ex)     ex+=1

Python program to print Prime numbers till N

 n=int(input("ENTER N : ")) for i in range(2,n+1):     temp=0     for j in range(2,i):         if i%j==0:             temp+=1     if temp==0:         print(i)

Python program for checking if entered number is Special or not

sum=0 fac=1 n=int(input("Enter N : ")) x=n while n!=0:     t=n%10     fac=1     for i in range(t,0,-1):         fac=fac*i     sum+=fac     n=n//10  if sum==x:     print("IT's A SPECIAL NUMBER!") else:     print("IT's NOT A SPECIAL NUMBER!")

Python program for finding Factorial of a number

fac=1 n=int(input("Enter N : ")) for i in range(n,0,-1):     fac=fac*i print(n,"! = ",fac)

Python program for reversing an Entered Number

 t=r=0 n=int(input("ENTER N : ")) while n!=0:     t=n%10     r=r*10+t     n=n//10 print('REVERSE : ',r)