Loop with Counter - Python Programming Exercise

In this exercise, you will develop a Python program that displays the numbers from 1 to 10 on the screen using a while loop. This task emphasizes the use of loop structures in Python, particularly the while loop, to perform repetitive tasks in a controlled manner. By completing this exercise, you will enhance your ability to implement iterative processes and work with loop counters. Mastering while loops is a fundamental skill in Python programming, enabling you to create dynamic and efficient Python programs that handle repetitive operations effectively.

 Category

Mastering Flow Control

 Exercise

Loop With Counter

 Objective

Develop a Python program that displays the numbers 1 to 10 on the screen using a "while" loop.

 Example Python Exercise

 Copy Python Code
# Initialize the counter variable
i = 1

# Use a while loop to display numbers from 1 to 10
while i <= 10:
    print(i)
    i += 1

 Output

1
2
3
4
5
6
7
8
9
10

 Share this Python Exercise

 More Python Programming Exercises of Mastering Flow Control

Explore our set of Python Programming Exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of Python. From variables and data types to control structures and simple functions, each exercise is crafted to challenge you incrementally as you build confidence in coding in Python.

  •  Multiplication Chart (Using While)

    In this exercise, you will develop a Python program that prompts the user to input a number and then displays its multiplication table using a while ...

  •  Descending Odd Values

    In this exercise, you will develop a Python program that displays the odd numbers from 15 to 7 in descending order using a while loop. This task ...

  •  Adding Values

    In this exercise, you will develop a Python program that prompts the user for an undetermined amount of numbers until the user enters 0. The program wil...

  •  Pair of Negative Values

    In this exercise, you will develop a Python program that prompts the user for two numbers and checks if both of them are negative. This task will help y...

  •  Single or Pair of Negative Values

    In this exercise, you will develop a Python program that prompts the user for two numbers and checks whether both are negative, only one is negative...

  •  Factors and Multiples

    In this exercise, you will develop a Python program that displays the numbers from 1 to 500 that are multiples of both 3 and 5 on the screen. You...