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
En esta página del sitio puede ver el video en línea Python program to print all odd numbers in a range || code in description de Duración hora minuto segunda en buena calidad , que subió el usuario Tech Tips 22 octubre 2022, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 52 veces y le gustó 1 a los espectadores. Disfruta viendo!