Site icon DataFlair

Python Program on Loops

Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python

Program 1

# 1    4     9    16     25 ....... n
# n=int(input("Enter the limit"))
# i=1  #intilization
# while(i<=n):
#     print(i*i,end=" ")
#     i=i+1

# WAP to print table of number

# n=int(input("Enter a number"))
# i=1
# while(i<=10):
#     print(n*i)
#     i=i+1

# Sum of Series
# n=int(input("Enter the limit"))
# i=1  #intilization
# sum=0
# while(i<=n):  # condition 
#     print(i)
#     sum+=i
#     i=i+1  # increment
# print("Total is: ",sum)    


# Fibbonacci Series
# 0  1  1    2   3   5   8    13    21   34   .............. n
# n=int(input("Enter the limit"))
# a=0
# b=1
# if(n==1):
#     print(a)
# if(n==2):
#     print(a)
#     print(b)
# if(n>2):
#     print(a,end=" ")    
#     print(b,end=" ")
#     i=1
#     while(i<=n-2):
#         c=a+b
#         print(c,end=" ")
#         a=b
#         b=c
#         i=i+1

# Factorial of number
n=int(input("Enter a number"))
f=1
while(n!=0):
    f=f*n
    n=n-1
print("Factorial is :",f)








 

Exit mobile version