Python program to print Even numbers in between x and y. Even numbers: The numbers which are divisible by 2 or the numbers whose remainder is 0 are called even numbers. Input : enter x value 1 enter y value 7 Output : even numbers between 1 and 7 are 2 4 6 Python program to display even numbers in range x , y #program to print even numbers in range x and y x=int(input("enter x ")) y=int(input("enter y ")) print(f"even numbers in between{x} and {y} are ") for i in range(x,y): if i%2==0: print(i) #use i,end=' ' to get output in single line Output : enter x 1 enter y 7 even numbers in between1 and 5 are 2 4 6
Python program to print odd numbers in between x and y. Odd numbers: The numbers which are not divisible by 2 or the numbers whose remainder is 1 are called odd numbers. Input : enter x value 5 enter y value 10 Output : odd numbers between 5 and 10 are 5 7 9 Python program to display odd numbers in range x , y #program to print odd numbers in range x and y x=int(input("enter x ")) y=int(input("enter y ")) print(f"odd numbers in between{x} and {y} are ") for i in range(x,y): if i%2!=0: print(i) #use i,end=' ' to get output in single line Output : enter x 5 enter y 10 odd numbers in between1 and 5 are 5 7 9