Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python program to print all odd numbers in a range

# 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 = " ")
Comment

Python program to print all even numbers in a range

for num in range(4,15,2):
  #here inside range function first no dentoes starting, second denotes end and third denotes the interval
    print(num)
Comment

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 = " ")
Comment

Python program to print all even numbers in a range

# 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: "))
 
#creating even starting range
start = start+1 if start&1 else start
  
 
#create a list and printing element
#contains Even numbers in range
[ print( x ) for x in range(start, end + 1, 2)]
Comment

Python program to print all odd numbers in a range

# Python program to print odd Numbers in a List
  
# list of numbers
list1 = [10, 21, 4, 45, 66, 93]
i = 0
  
# using while loop        
while(i < len(list1)):
      
    # checking condition
    if list1[i] % 2 != 0:
        print(list1[i], end = " ")
      
    # increment i  
    i += 1
Comment

PREVIOUS NEXT
Code Example
Python :: python calculator source code 
Python :: pyhton apend to list 
Python :: convert utm to decimal degrees python 
Python :: seaborn documentation x axis range 
Python :: linear search implementation 
Python :: html element python 
Python :: print with color python 
Python :: how to count number from 1 to 10 in python 
Python :: sqlite database python 
Python :: not intersection list python 
Python :: python add hyphen to string 
Python :: date to timestamp python 
Python :: How determine if a number is even or odd using Modulo Operator 
Python :: generate barcode using python 
Python :: Python NumPy stack Function Example with 2d array 
Python :: async webpage 
Python :: change xlabel python 
Python :: maximize difference codechef 
Python :: python iterating over a list 
Python :: run python in c ++ 
Python :: python check if false in dict 
Python :: boto3 python s3 
Python :: change a decimal to time in datetime python 
Python :: how to address null in python 
Python :: scikit learn random forest 
Python :: value list in django 
Python :: django csrf failed 
Python :: bitwise xor in python 
Python :: How to Get the length of all items in a list of lists in Python 
Python :: remove dict last element 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =