Skip to content

Latest commit

 

History

History
36 lines (32 loc) · 1.6 KB

File metadata and controls

36 lines (32 loc) · 1.6 KB

#Loops Exercises Part 1: Exploring Range Do the following exercises in the Python interpreter.

Explore range

You do not need to type up answers to these.

  1. Type range(5) and press enter. What happens?
  2. Type range(3.14) and press enter. What happens?
  3. Type range(-8) and press enter. What happens?
  4. Type range(0) and press enter. What happens?
  5. Type range(1) and press enter. What happens?
  6. Type range(1,5) and press enter. What happens?
  7. How is this different than range(5)?
  8. Type range(5,1) and press enter. What happens?
  9. Now type range(5,1,-1) and press enter. What happens?
  10. How is this different than range(5,1)?
  11. Type range(0,-5) and press enter. What happens?
  12. Type range(-5,0) and press enter. What happens?
  13. How is this different than range(0,-5)?
  14. How would you get the numbers from 0 down to -4? (Hint: look at #8)
  15. Type range(10) and press enter. What happens?
  16. Type range(0,10) and press enter. What happens?
  17. Type range(0,10,1) and press enter. What happens?
  18. Type range(0,10,2) and press enter. What happens?
  19. Type range(0,10,1+1) and press enter. What happens?

Describe how range works

Please record your answers to these questions by using the edit button on GitHub.
Make sure you have pushed your lists exercises before making any commits on GitHub, otherwise you will have to make a merge commit later.

  1. What does range do with a single argument?
  • [Your answer here]
  1. What do the arguments mean if there are 2?
  • [Your answer here]
  1. What does the third argument mean?
  • [Your answer here]