Descending Odd Values in Python

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 focuses on understanding loop structures, particularly how to control iterations and conditions to achieve specific patterns in Python programming. By completing this exercise, you will gain valuable experience in working with conditional statements and loop counters. Understanding how to generate sequences such as odd numbers in reverse order helps build a strong foundation in writing efficient and flexible Python programs.



Group

Mastering Flow Control in Python

Objective

Develop a Python program that displays the odd numbers from 15 to 7 (in descending order) on the screen using a "while" loop.

Example Python Exercise

 Copy Python Code
# Initialize the counter variable
i = 15

# Use a while loop to display odd numbers from 15 to 7 in descending order
while i >= 7:
    if i % 2 != 0:
        print(i)
    i -= 1

 Output

15
13
11
9
7

Share this Python Exercise

More Python Programming Exercises of Mastering Flow Control in Python

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.

  • Adding Values in Python

    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 Python

    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 Python

    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 Python

    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...

  • Repeated Value in Python

    In this exercise, you will develop a Python program that prompts the user for a number and a quantity, then displays that number repeated as many...

  • Access Code in Python

    In this exercise, you will develop a Python program that prompts the user to enter their login and password (both must be integer numbers). The p...