Omniadisce

Computational physics 2.4: for loops: doing it again

Lesson Beginner

Join free to take this lesson

Anyone can look around, but taking a lesson needs a free account. With one, your answers are checked step by step and your progress is saved, so you can stop and pick up where you left off on any device.

13 steps ยท about 20 min

By the end you can

  • Write a for loop with range, and indent its body
  • Say which numbers range(n) and range(a, b) give
  • Use range(1, n + 1) to count from 1 to n
  • Use the loop's number in a formula
  • Tell a line inside the loop from a line after it

Who it is for: After lesson 2.2: you can write an indented body.

The steps

  1. Three times
  2. for: once for each number
  3. range(5) is 0, 1, 2, 3, 4
  4. range(4)
  5. Run a loop
  6. Count further
  7. range(1, n + 1): from 1 to n
  8. Seconds 1 to 10
  9. Use t in the body
  10. Speeds of a falling stone
  11. After the loop
  12. How many times?
  13. range in your own words

Discussion 0 comments

Log in to join the discussion.

× Enlarged view