‍
Loops
‍

Excercise – 1:

Use While to Print count 5 times

count = 0
‍
if count < 5:
 print (“Hello, I am an if statement and count is”, count)

while count < 5: #Condition
 print (“Hello, I am a while and count is”, count)
 count += 1

‍
Excercise – 2:

‍
Print Square of a numbers from 1 to 10 using while

num = 1
while num <= 10:  # Fill in the condition  
   # Print num squared  
   print (num * num)
‍
   # Increment num (make sure to do this!)  
   num += 1

Excercise – 3:
‍

Print Square of a numbers from 1 to 5 using for

numbers  = [1, 2, 3, 4, 5]  #Using Lists
print (numbers)

print(“Squared Numbers are:”)

# Add your loop below!
for num in numbers:
 print num * num

‍

print(“Squared Numbers are:”)

# Add your loop below!
for num in range(1,6): #Using Range
 print (num * num)

‍

‍

‍

Leave a Reply

Your email address will not be published. Required fields are marked *