Menu Bar

Horizontal Scrollable Menu

ads

Search This Blog

Python | Odd and Even using Append

Odd and Even using Append in Python


If you divide a number by 2 and it gives a 
remainder of 0 then it is known as even number,
 otherwise an odd number.
Algorithm
step1:start
step2:def variable(abc):
sep3:take empty set of odd and even
step4:use loop in number you given
step5:check the condition if its true 
      then append in even else odd 
step6:return output
step7:enter number 
step8:print(def_variableName(pass_number))
step9:end

Example

def odd_even(num):

    odd=[]

    even=[]

    for i in num:

        if i%2 == 0:

            even.append(i)

        else:

            odd.append(i)

    output_num=[odd,even]

    return output_num

number=[1,2,3,12,15,6,7,8,9]

print(odd_even(number))

No comments:

ads3