Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. TOPIC: LOOPS
  2.  
  3. OBJECTIVES
  4. Be able to define loops
  5. Be able to understand the uses of loops
  6. Be able to implement loops
  7.  
  8. Using Python
  9.  
  10. DEFINITION:
  11. Basically, loops or looping in programming is a way of facilitating the repetition of an action finitely or infinitely based on a certain condition[s] without rewriting the code that implements the action.
  12.  
  13. APPLICATION OF LOOPS(considering the learner has knowledge of data structures):
  14. -Printing items in a list/array, dictionary or set.
  15. -Adding numbers in a range
  16. *Basically, anything that needs to be done repeatedly
  17.  
  18. LOOPS IN PYTHON:
  19. -For loop
  20. -While loop
  21.  
  22. Examples/Implementation of loops:
  23. >>names = ['John', 'Mary', 'Jane']
  24. >>for name in names:
  25. >> print(name)
  26. OUTPUT
  27. John
  28. Mary
  29. Jane
  30.  
  31. >>count = 0
  32. >>while (count < 3):
  33. >> print('The count is:', count)
  34. >> count = count + 1
  35. >>print "THE END!"
  36.  
  37. OUTPUT:
  38. The count is: 0
  39. The count is: 1
  40. The count is: 2
  41. The count is: 3
  42. THE END!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement