Day -10
For Loop :
For loop is used to iterate a sequence of data items.
let's solve some examples:
- Write a python program to find the factorial of a number :
n=int(input("Enter the number - "))
m=1
for i in range(1,n+1):
m=m*i
print("The factorial of number is -",m)
output :
- Write a python program to print the sum of the digit of a number in the range.
n=int(input("enter the number "))
m=int(input("Enter second number"))
sum=0
for i in range(n,m+1):
sum=sum+i
print(sum)
output:
- Write a program to print the multiplication table of 7
n=int(input("Enter the number :"))
for i in range(1,11):
print(n,"*",i,"=",n*i)
output :
More problems on for loop :
Write a program to convert temperature in Fahrenheit to centigrade.
Write a program to reverse a number
Write a program to print the following patterns
-
In my next blog, You will get to know! How to write a program to solve patterns by using for loop.
Thank you !!