script_1.py - Count from 1 to 10
Code
Explanation
Line 4: for i in range(1, 11):
- for is a loop keyword that iterates over a sequence
- i is the loop variable (gets a new value each iteration)
- range() is a built-in function that generates sequence of integers
- range(1, 11) creates numbers from 1 to 10 (start inclusive, stop exclusive)
- Stop value 11 means it stops before 11 (doesn't include 11)
- i takes values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Colon : marks start of loop body
Line 5: print(i)
- Indented code is the loop body (executes for each value of i)
- Runs 10 times total
- First iteration: i=1, second: i=2, etc.