Q.14 write python code to add the odd numbers up to (and including) a given value N
and print the result.
Answers
Answered by
2
Answer
This Python program allows the user to enter the maximum limit value. Next, Python is going to print odd numbers from 1 to the user entered a maximum limit value.
In this example, Python For Loop makes sure that the odd numbers are between 1 and maximum limit value.
INPUT
# Python Program to Print Odd Numbers from 1 to N
maximum = int(input(" Please Enter any Maximum Value : "))
for number in range(1, maximum + 1):
if(number % 2 != 0):
print("{0}".format(number))
Similar questions