Print Numbers from 1 to 10
Print one through ten with a for loop. Beginners trace range boundaries, repeated print calls, and the excluded stopping value without reading user input.
1# Print numbers 1 to 102for i in range(1, 11):3 print(i)
Output
1 2 3 4 5 6 7 8 9 10
In this one
- Read range bounds
- Trace repeated output
- Understand excluded stops
How it works
- 1
Create range(1, 11).
- 2
Assign each supplied value to i.
- 3
Print i with its default newline.
Edge cases
Is eleven printed?
Is eleven printed?
No. range excludes its stop value.
Is input required?
Is input required?
No. Both bounds are written directly in the code.
What's going on
range(1, 11) supplies the integers one through ten. Each value is assigned to i before the indented print runs.
The stop value eleven is excluded. print adds a newline each time, so this is ten separate lines, not a single string containing a range. Moving print outside the loop would change the result completely.
Is eleven printed? No. range excludes its stop value.
Is input required? No. Both bounds are written directly in the code.
Quiz
Tap an option. The answer stays hidden until you pick.
Question 1
How often does print run?
Pick an answer to check it.
Question 2
Is eleven printed?
Pick an answer to check it.
Questions people ask
Is eleven printed?
No. range excludes its stop value.
Is input required?
No. Both bounds are written directly in the code.
How often does print run?
Ten times.
๐Related Content
- ๐
Phase 2 - Learn Concepts
Review Phase 2 concepts and explanations
- ๐
Phase 2 - Quiz
Test your Phase 2 understanding with quiz questions
- ๐ป
Phase 2 - All Practice Problems
Explore all practice problems for Phase 2
- ๐
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- ๐ง
Logic Building Overview
Learn about the complete logic building curriculum