
Explanation:
The range() function in Python generates a sequence of numbers. It starts from the start parameter (inclusive) and ends at the stop parameter (exclusive). The correct syntax to print numbers from 1 to 10 is for i in range(1, 11): print(i), where 1 is the start and 11 is the stop, ensuring numbers 1 through 10 are printed.
Which Python code snippet correctly prints numbers from 1 to 10?
A
for i in range(10): print(i)
B
for i in range(1, 11): print(i)
C
for i <- 1 to 10: print(i)
D
for(int i = 1; i <= 10; i++) print(i)
E
for i in range(1 to 10): print(i)
No comments yet.