Give a segment of python code that will print the numbers 1 to 7, each one on a new line

for x in range(1,8) : print(x) The range(1,8) function gives us an array of numbers from 1 to 7. The number on the right is the upper bound of the numbers which is why only 1 to 7 is returned.From here, a for loop is used, basically saying for each number inside the array, print this number.

JC
Answered by Jamie C. Python tutor

3372 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

What is the difference between a for loop and a while loop.


Whats is the difference between a function and a procedure?


Describe both For-loops and While-loops and explain how you can simulate the effect of a for loop with a while loop with an example.


[Exam style] Python is an interpreted language. Explain what this means and how interpreted languages differ from compiled languages.


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

MyTutor is part of the IXL family of brands:

© 2025 by IXL Learning