loops and arrays

Cards (8)

  • Everyday there are some tasks which need to be done repeatedly. Loops are programming elements which repeat a portion of the code for a set number of times till the desired process is complete.
  • there are 3 kinds of loops :- while loop, for loop and nested loop
  • The While loop can execute a set of commands till the condition is true While Loops are also called conditional loops. Once the condition is met then the loop is finished
  • For loop is needed for iterating over a sequence
  • A loop that occurs within another loop is called nested loop.
  • Arrays are collection of similar data type variables . Arrays do not support different data types in same collection. for ex you can make an array of strings and an array of integers but not an array of strings+integers.
  • SORTING AN ARRAY:- arr1 = [34,78,9,0,3]
    arr1.sort()
    game.splash(arr1)
  • SEARCHING AN ARRAY:- arr1 = [34,78,9,0,3]
    game.splash(arr1.index(9))