184_notes:loops

This is an old revision of the document!


Coding: Loops

You can think of coding as writing instructions for a computer to follow. Let's say I want my computer to print out each of the numbers from 1 to 100. In Python, printing a number is easy:

print(1)

This will print the number 1. Printing all the numbers from 1 to 100 is a little more challenging though. Here's one way:

print(1)
print(2)
print(3)
print(4)
print(5)
...

That will take a long time, and programmers are lazy! They don't want to spend their day writing the same thing over and over (neither do physicists).

  • 184_notes/loops.1649901043.txt.gz
  • Last modified: 2022/04/14 01:50
  • by woodsna1