Monday, 24 June 2019

Loops in Python

Loops (Iterative Statements)

Example:
s="Hyderabad"
for a in range(5):
    print(s)


If we want to execute a group statements (or single statement) multiple times then we use Iterative statements:


There are two types:
1.   for loop
2.   while loop

for loop:
If we want to execute some action for every element present in some sequence.
Syntax:
for variable in sequence:
  body
note: sequence means string,list,set,tuple or any other collections.

Assignment:

Find the factorial of a given number using for loop:



Next Topic: for loop
Previous Topic: if..elif..else statemnet

1 comment:

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(&qu...