#WAP that print the factorial of a no...e.g. 10 ''' f=1 for i in range(1,11): f=f*i print(f) ''' #WAP that print the factorial of a no from 1 to 10 ''' f=1 for i in range(1,11): f=f*i print(f) ''' #---------------------------------------------------- # WAP n n2 n3 n4 n5.... ''' import math n=int(input("enter any no")) p=int(input("enter the power")) for i in range(p+1): #d=int(math.pow(n,i)) d=n**i print(d) ''' #---------------------------------------------------------- '''Choice based/menu driven program while True: print("1. print the series") print("2. area of rectangle") print("3. factorial of a no") print("4.exit") ch=int(input("enter the choice ")) if ch==1: import math n=int(input("enter any no")) p=int(input("enter the power")) for i in range(p+1): #d=int(math.pow(n,i)) d=n**i print(d) elif (ch==2): l=int(input("enter length")) b=int(input("enter breadth")) print("area of rectangle",l*b) elif ch==3: n=int(input("enter a no")) f=1 for i in range(1,n+1): f=f*i print(f) elif ch==4: break ''' #------------------------------------------------ '''Choice based/menu driven program print() print("1. print the series") print("2. area of rectangle") print("3. factorial of a no") ch=int(input("enter the choice ")) if ch==1: import math n=int(input("enter any no")) p=int(input("enter the power")) for i in range(p+1): #d=int(math.pow(n,i)) d=n**i print(d) elif (ch==2): l=int(input("enter length")) b=int(input("enter breadth")) print("area of rectangle",l*b) elif ch==3: n=int(input("enter a no")) f=1 for i in range(1,n+1): f=f*i print(f) else: print("enter valid choice") ''' #---------------------------------------------- #Write a program to display the n terms of series and their sum. #1 + 1/2 + 1/3 + 1/4 + 1/5 ... 1/n terms ''' n=int(input("enter any no")) s=0 for i in range(1,n+1): s=s+ 1/i print(s) ''' ##Write a program to display the n terms of series and their sum. #1 + 1/22 + 1/32 + 1/42 + 1/52 ... 1/n2 terms ''' n=int(input("enter any no")) s=0 for i in range(1,n+1): s=s+ (1/i)**2 print(s) ''' #------------------------------------------------------ ##Write a program to display the n terms of series and their sum. #1 + 1/22 + 1/33 + 1/44 + 1/55 ... 1/nn terms n=int(input("enter any no")) s=0 for i in range(1,n+1): s=s+ (1/i)**i print(s)