This is a Python Program to print odd numbers within a given range.
The program takes the upper and lower limit and prints all odd numbers within a given range.
Here is the source code of the Python Programto print odd numbers within a given range. The program output is also shown below.
lower=int(input("Enter the lower limit for the range:"))
upper=int(input("Enter the upper limit for the range:"))
for i in range(lower,upper+1):
1. User must enter the upper range limit and the lower range limit.
2. The for loop ranges from the lower range limit to the upper range limit.
3. The expression within the if-statement checks if the remainder obtained when the number divided by 2 is one or not (using the % operator).
4. If the remainder isn’t equal to 0, the number is odd and hence the number is printed.