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

3077 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

With the help of Pandas and Numpy library create a DataFrame with the columns "Name", "Surname", "Age" and "Gender", create as many rows as you want. Print out the result.


How would you write a while loop to print all even numbers from 1-10?


Write a Python script to take a product name as input and then automatically google search reviews for it and open the top 3 search results in different tabs


Create an rock, paper, scissors game. The user should input one option, and the computer should play randomly.


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences