Learn about Program to Print Odd Number from 1 to 100 in the below code example. Also, refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
Program to Print Odd Number from 1 to 100
# Python program to print all odd numbers in given range
# range
start, end = 1, 100
print('All odd number in the range')
for num in range(start, end + 1):
# check number is odd or not
if num % 2 != 0:
print(num, end = " ")
Output:
All odd number in the range 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Find Odd Numbers in the Range Python