WAP to print the all the odd number between 20 to 50 and print the sum of it at the end.
Answers
Answered by
0
Answer:
Input: start = 4, end = 15
Output: 5, 7, 9, 11, 13, 15
Input: start = 3, end = 11
Output: 3, 5, 7, 9, 11
Example #1: Print all odd numbers from given list using for loop
Define start and end limit of range. Iterate from start till the range in the list using for loop and check if num % 2 != 0. If the condition satisfies, then only print the number.
# Python program to print odd Numbers in given range
start, end = 4, 19
# iterating each number in list
for num in range(start, end + 1):
# checking condition
if num % 2 != 0:
print(num, end = " ")
Similar questions
World Languages,
3 months ago
English,
7 months ago
Math,
7 months ago
Psychology,
10 months ago
Political Science,
10 months ago
Math,
10 months ago