Python basics

  Loops:

While loop:

  while statement :

       print()

we can come out of the loop by using break statement.


for loop:  

  • to print list

            for i in (1,2,3,4):

                 print(i)

  • for loop for range of values

for i in range (100):

           print(i)

  • for loop for range with starting values 

            for i in range (20,100):

               print(i)

  • for loop for range with starting values  and skip value in middle 

                for i in range (20,100,2):

                      print(i)

Comments

Popular posts from this blog

Mean, Var, and Std in numpy HackerRank

Min and Max in numpy HackerRank

Collections.deque() HackersRank Solution