Answers for "use of the for loop"

5

for loop

# example of forloop and return through factorial
def fact(m):# function factorial
    a=1
    for e in range(1,m+1):#we will be using for loop
        a*=e
    return a#return function
x= 5 # put the value in x eg, 5
d=fact(x)
print(d)

output:
120==5*4*3*2*1
-------------------------------------------------------------------------------
Posted by: Guest on November-28-2021
3

for loop

#for loop
a=b=c=0
for m in range(0,10):
    a=int(input('the number1:'))
    b=int(input('the number2:'))
    if b==0:
        print('intermediate')
        break
    else:
        c=a//b
        print('the answer=',c)
print('conclusion')
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Posted by: Guest on November-28-2021

Browse Popular Code Answers by Language