Python program to print all odd numbers in a range
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 = " ")
Output:
5 7 9 11 13 15 17 19
Python program to print Even Numbers in given range
start = int(input("Enter the start of range:"))
end = int(input("Enter the end of range:"))
iterating each number in list
for num in range(start, end + 1):
checking condition
if num % 2 != 0:
print(num)
Output:
Enter the start of range: 3
Enter the end of range: 7
3
5
7
Uncomment the below two lines for taking the User Inputs
#start = int(input("Enter the start of range: "))
#end = int(input("Enter the end of range: "))
Range declaration
start = 5
end = 20
if start % 2 != 0:
for num in range(start, end + 1, 2):
print(num, end=" ")
else:
for num in range(start+1, end + 1, 2):
print(num, end=" ")
Output
5 7 9 11 13 15 17 19
Python program to print Even Numbers in given range
start = int(input("Enter the start of range: "))
end = int(input("Enter the end of range: "))
#create a list that contains only Even numbers in given range
even_list = range(start, end + 1)[start%2::2]
for num in even_list:
print(num, end = " ")
Enter the start of range: 3
Enter the end of range: 11
3 5 7 9 11
def odd(num1,num2):
if num1 num2:
return
print(num1+1,end=" ")
return odd(num1+2,num2)
num1=4;num2=15
odd(num1,num2)
Output
5 7 9 11 13 15
Python program to print all odd numbers in a range
Python program to print all even numbers in a range
Python program to print odd numbers in a List
Python program to print even numbers in a list
Python program to find second largest number in a list
Python program to find largest number in a list
Python program to clear a list || code in description
Python program to find sum of elements in list
python code to Check if element exists in list or not
Python Program for Sum of squares of first n natural numbers
Python Program for factorial of a number
Python code To find compound interest #shorts #python
Python program to find the maximum of two numbers #shorts #python
Python Program to Convert Kilometers to Miles
Python Program to Generate a Random Number #shorts #python
На этой странице сайта вы можете посмотреть видео онлайн Python program to print all odd numbers in a range || code in description длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Tech Tips 22 Октябрь 2022, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 52 раз и оно понравилось 1 зрителям. Приятного просмотра!