Python Example Program to Check if a Number is Even or Odd ( User Input )

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 เม.ย. 2019
  • In this tutorial you will learn to write a Python Program to Check if a Number is Even or Odd.
    First we ask the user to enter a number and we store that in a variable.
    Then we divide that number by 2 and we check for the remainder value.
    if the remainder is 0 then it means that the number is even, else the number is odd,
    Finally we display the result on the screen.
    our Social Media Pages
    / exampleprogram
    / exampleprogram
    / examplecomputerprogram
    Our Website
    www.ExampleProgram.com
    #PythonProgramming #ExampleProgram

ความคิดเห็น • 178

  • @darthvitiate7373
    @darthvitiate7373 2 ปีที่แล้ว +17

    in the end how you mentioned dislike the video if you didnt like it, this video was exactly what it had to be straight to the point and clearly explained for everyone even people who have never seen code before
    you got a new subscriber

  • @jananjaymedhi1251
    @jananjaymedhi1251 3 ปีที่แล้ว +29

    wonderful explanation.......this video has cleared all my doubts on this even and odd number program......I am literally thanking you more than a hundred times for this wonderful help......Thank you :D

  • @Chick0714
    @Chick0714 2 ปีที่แล้ว +2

    So easy n understandable video for even or odd program 😊😇

  • @KoenigseggEditz856
    @KoenigseggEditz856 ปีที่แล้ว

    all other videos were just gonna show you the code without any explanation and thats it, although, you did an amazing explanation, love from Saudi Arabia ❤️

  • @ramaneshwark2771
    @ramaneshwark2771 3 ปีที่แล้ว +15

    well detailed explanation....thank you...and make many more video for class 11 and 12th!!

  • @mangaMahwaRecap
    @mangaMahwaRecap 2 ปีที่แล้ว +5

    Your explanation was very to the point and simple, I loved it. I am subscribing to your Chanel.

  • @catmistrysupport2292
    @catmistrysupport2292 3 ปีที่แล้ว +12

    print("number is odd") if int(input("number: "))%2 else print("number is even")

    • @sera_phim_
      @sera_phim_ 2 ปีที่แล้ว +1

      hippity hoppity your code is my property

    • @chugh97
      @chugh97 2 ปีที่แล้ว

      Not quite because you can also divide a odd number

    • @catmistrysupport2292
      @catmistrysupport2292 2 ปีที่แล้ว

      @@chugh97 ?

    • @legengmer5567
      @legengmer5567 2 ปีที่แล้ว

      Can we write this??

    • @Haniya-dz2zj
      @Haniya-dz2zj 5 หลายเดือนก่อน +1

      ​@@legengmer5567no you can eat this

  • @asitharathnayake4314
    @asitharathnayake4314 11 หลายเดือนก่อน +1

    been trying to do this for hours and watched ur video n did it in 1 min...tysmmmmm

  • @yvng4697
    @yvng4697 3 ปีที่แล้ว +2

    This is well explained!!
    Thank u!!

  • @taehyung_my_lyf6492
    @taehyung_my_lyf6492 3 ปีที่แล้ว +2

    Thank u so much sir!!! Your explanation is so good.

  • @asmkjm917
    @asmkjm917 ปีที่แล้ว +1

    thank you so much, you're a life saver!

  • @sarvesh7046
    @sarvesh7046 ปีที่แล้ว +2

    Thank you!

  • @akshayakrishnan7778
    @akshayakrishnan7778 2 ปีที่แล้ว +2

    Your explanation is very useful and interesting thankyou

  • @sadikff583
    @sadikff583 2 ปีที่แล้ว +2

    I am speechless
    Mind blowing explanation Sir👌

  • @killergaming3d780
    @killergaming3d780 ปีที่แล้ว +1

    Thanku sir today was my computer practical exam and i scores full in it i am subscribing ur channel

  • @lukeBalmar
    @lukeBalmar 4 ปีที่แล้ว +28

    num1 = int(input("Enter your number to check: "))
    if num1 % 2 == 0:
    print(f'{num1}' ' is even')
    else:
    print(f'{num1}' ' is odd')

  • @lucillewiid5476
    @lucillewiid5476 2 ปีที่แล้ว

    Really great video explaining it very nicely!

  • @nmrsa7331
    @nmrsa7331 ปีที่แล้ว

    thanks for this video , It wsa helpful .
    I solved my homework by your video

  • @ramSitaEditz
    @ramSitaEditz 3 ปีที่แล้ว +1

    Thanks you sir

  • @binglu30
    @binglu30 2 ปีที่แล้ว +1

    my program is this: nums = input("Enter 2 numbers, or press 'q' to quit:")
    remainder = nums % 2
    while(nums != "q"):
    if (remainder == 0):
    print(nums, "is an even number")
    else:
    print(nums, "is the bigger number")

  • @jimgr1487
    @jimgr1487 ปีที่แล้ว

    Never thought about that

  • @programmingbyrawaha6706
    @programmingbyrawaha6706 3 ปีที่แล้ว +1

    Thank you so much!
    I am also trying to teach Python in my channel

  • @mdafroj8546
    @mdafroj8546 ปีที่แล้ว +1

    Thank you sir 😎😍😍

  • @meeteshchouhan
    @meeteshchouhan ปีที่แล้ว +1

    Thanks 😊

  • @kaursimran191
    @kaursimran191 3 ปีที่แล้ว +1

    Sir ur videos r so helpful to me☺☺

    • @ExampleProgram
      @ExampleProgram  3 ปีที่แล้ว

      glad my tutorials are helping you
      keep learning :)

  • @alvinmathew5691
    @alvinmathew5691 3 ปีที่แล้ว +2

    thanks it help me a lot

  • @bhagyasripriyadarsani7127
    @bhagyasripriyadarsani7127 4 ปีที่แล้ว +2

    Thank u so much sir

  • @dwxzgod5967
    @dwxzgod5967 3 ปีที่แล้ว +1

    Thank you so much sir❤

  • @shainamagne
    @shainamagne 2 ปีที่แล้ว +1

    Thanks bruhh

  • @sreejasircar6781
    @sreejasircar6781 ปีที่แล้ว +1

    Thank you

  • @kashishsirohiwal6089
    @kashishsirohiwal6089 ปีที่แล้ว +1

    Thankyou so much for this🙂🌼

  • @nunnakalyan2536
    @nunnakalyan2536 2 ปีที่แล้ว +1

    nice info keep continue.sir

  • @animeshsarkar7717
    @animeshsarkar7717 2 ปีที่แล้ว +1

    Thanks brother ❤️❤️

  • @deepghosh4030
    @deepghosh4030 2 ปีที่แล้ว +1

    Thank you❤

  • @iitian2026Real
    @iitian2026Real ปีที่แล้ว +1

    Such a wonderful video and such a good explanation thanks!

  • @Mrsomverma
    @Mrsomverma 2 ปีที่แล้ว +2

    Great

  • @Versatile77
    @Versatile77 ปีที่แล้ว +1

    Very nice sir

  • @derrickpham7987
    @derrickpham7987 2 ปีที่แล้ว +1

    thank u

  • @anita5009
    @anita5009 3 ปีที่แล้ว +2

    It worked....!😄

  • @youmewe
    @youmewe 5 ปีที่แล้ว +2

    Very nice

  • @venkateshk8634
    @venkateshk8634 2 ปีที่แล้ว +1

    tq sir it helps me

  • @muskansheikh
    @muskansheikh 4 ปีที่แล้ว +2

    😊thanks

  • @Yaminianusuri666
    @Yaminianusuri666 3 ปีที่แล้ว +1

    Tq so much

  • @shokeennikeeta
    @shokeennikeeta ปีที่แล้ว +1

    i did it 😯🥳

  • @DignoJapan00
    @DignoJapan00 ปีที่แล้ว +1

    👌

  • @chinmaysurve3565
    @chinmaysurve3565 3 ปีที่แล้ว

    Ty😭

  • @muhammadtalhakhan2849
    @muhammadtalhakhan2849 3 ปีที่แล้ว +1

    thanks a lot sir. very very simple and good wording you used and I subscribed you

  • @vandnapahuja76
    @vandnapahuja76 3 ปีที่แล้ว

    Thank u sir

  • @seniome474
    @seniome474 ปีที่แล้ว

    hey, i have a doubt that isnt related but, what if i wanna add 2 numbers with input and then if someone inputs a word then type a message saying "please enter a number" ?

  • @BRRTa10
    @BRRTa10 ปีที่แล้ว +2

    the way you break down the code is incredible I've never felt more confident coding up till now

  • @ToxicJBeats
    @ToxicJBeats 3 ปีที่แล้ว +2

    What If We Want The Username To Enter Two different numbers and we have to find which one is even and which one is odd.
    Please Tell How Can We Do That What's The Python Program For That 🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏

    • @dagdbot83
      @dagdbot83 3 ปีที่แล้ว

      If the input is only in one line then what I will do is
      x = int(input())
      x = x.split() #Leave blank if you want to remove spaces to make a list
      Then you can make your code

  • @arkktres
    @arkktres 7 หลายเดือนก่อน

    Hi! What if the user wanted to know the even numbers between a range of negative to positive integers? Is it possible or it can only print positive integer/s?

  • @lavanyathakur3716
    @lavanyathakur3716 4 ปีที่แล้ว +4

    Sir there invalid syntax is coming

    • @anita5009
      @anita5009 3 ปีที่แล้ว

      Same...here..

  • @itsameme9405
    @itsameme9405 5 หลายเดือนก่อน

    u are respected 6:21

  • @kaursimran191
    @kaursimran191 3 ปีที่แล้ว +1

    Are u teacher or professional programmer???

  • @Anitadevi-st2jl
    @Anitadevi-st2jl ปีที่แล้ว +1

    X=int(input("Enter the number here"))
    if (x % 2 == 0):
    Print(X,"is an even number")
    Else:
    Print(X,"is an odd number")

  • @aurasehdev4336
    @aurasehdev4336 3 ปีที่แล้ว +1

    Very nice explaination... Just the pronunciation of remainder is not rim-i-nder, its rim-ain-der :) Just saying... :D

  • @craftideasbyniru6265
    @craftideasbyniru6265 2 ปีที่แล้ว +6

    a=int(input("enter the number"))
    If(a%2===0):
    Print("the number is even")
    Else:
    Print ("the number is odd")
    Sir, is this correct? Please reply

  • @Rushil.K
    @Rushil.K 11 หลายเดือนก่อน +2

    hi i did not understand why you have used % instead of /

    • @ExampleProgram
      @ExampleProgram  11 หลายเดือนก่อน

      / is division operator
      % is modulus operator
      % is used to get the remainder value when we divide a number by another number

  • @ishaqureshi6799
    @ishaqureshi6799 2 ปีที่แล้ว

    when I'm typing print(number, " is an even number ") its coming error expected an indented block after 'if' statement on line 1

  • @krithikakrithika5821
    @krithikakrithika5821 2 ปีที่แล้ว +2

    Sir pls say how to change the font size

  • @moodymeee7395
    @moodymeee7395 3 ปีที่แล้ว +2

    number = int (input ("Enter the number:"))
    if number % 2 == 0:
    print (" Number is Even:")
    else:
    print ("Number is Odd:")

  • @shivamani3839
    @shivamani3839 3 ปีที่แล้ว +1

    hello ...!
    can u expailn this program sir ...!
    string Rotation Q
    input is : python and onpython
    expected output is : 2
    pls if any body can u write a program plz .....!

  • @eekshitasai2663
    @eekshitasai2663 2 ปีที่แล้ว

    Sir who to prees modular division symbol % in codetantra in mobile key board

  • @ganeshgane7466
    @ganeshgane7466 ปีที่แล้ว +1

    sir how to find special number vidieo

  • @lloydvillahermosa5226
    @lloydvillahermosa5226 2 ปีที่แล้ว

    How do I make it so that when I enter something that is not a whole number it says "Invalid"

  • @aktechnolgy632
    @aktechnolgy632 9 หลายเดือนก่อน

    The most beautiful English accent doesn't exis-

  • @kuchbhi6078
    @kuchbhi6078 ปีที่แล้ว

    agr mai float (22.2) input kr raha hu toh ye o/p odd de raha h.. why?

  • @Lavanya__xswl
    @Lavanya__xswl ปีที่แล้ว

    Please write a program to check whether the given number is even or odd *_using class_* in python

  • @Satish_0205
    @Satish_0205 ปีที่แล้ว +1

    Mehak loveyou❤

  • @lilyloo8791
    @lilyloo8791 3 ปีที่แล้ว +2

    Never Mind

  • @Satish_0205
    @Satish_0205 ปีที่แล้ว

    Achaaa

  • @jeevalgoyal4998
    @jeevalgoyal4998 2 ปีที่แล้ว

    Noice

  • @allinoneunofficial2079
    @allinoneunofficial2079 2 ปีที่แล้ว

    What if we enter 0? It is displaying it as even! What to do?

  • @kirankumarshiremath3035
    @kirankumarshiremath3035 2 ปีที่แล้ว

    10 is even or odd number sir....?

  • @gawthamkrishna6833
    @gawthamkrishna6833 2 ปีที่แล้ว +2

    def oddeven(a):
    if (a%2==0):
    return 1
    else:
    return 0
    num = int(input("Enter a number: "))
    if (oddeven(num)==1):
    print("The given number is Even")
    else:
    print("The given number is Odd")
    this one is with function :)

    • @devanandanbs8714
      @devanandanbs8714 2 ปีที่แล้ว

      wow this one is different from other

    • @gawthamkrishna6833
      @gawthamkrishna6833 2 ปีที่แล้ว

      @@devanandanbs8714 yup I used function so it made the program difficult

  • @mohammadaminhanif9750
    @mohammadaminhanif9750 ปีที่แล้ว

    how about zero? this number is not even or odd !!! how can I solve this problem?

  • @444gamingff7
    @444gamingff7 ปีที่แล้ว +1

    Har Har Mahadev ❤️❤️❤️❤️

  • @dilipkumararulappan5845
    @dilipkumararulappan5845 7 หลายเดือนก่อน

    Display numbers from 1 to 50. Numbers divisible by 3 should be
    displayed as “Accord”, divisible by 5 should be displayed as “matrix”.
    Numbers divisible by 3 and 5 should be displayed as “Accord info"Matrix" how to create the code in python

  • @weeducation99
    @weeducation99 3 ปีที่แล้ว +2

    what is the editor name

  • @lilyloo8791
    @lilyloo8791 3 ปีที่แล้ว +4

    My code is not working
    number=int(input("Enter A Integer Number"))
    remainder=number % 2
    if (remainder==0):
    print(number," is an even number")
    else:
    print(number," is an odd number")

    • @yvng4697
      @yvng4697 3 ปีที่แล้ว +1

      Did u tried it on idle?

    • @dilutedchaos
      @dilutedchaos 2 ปีที่แล้ว

      if (remainder==0):
      The code isn't working because of the parentheses. Don't forget to add spaces between a value and the operator like:
      if remainder == 0:
      or
      remainder = number % 2

  • @adiflied
    @adiflied ปีที่แล้ว +1

    Whenever I press Enter it asks for the input right away

    • @ExampleProgram
      @ExampleProgram  ปีที่แล้ว

      post you code

    • @adiflied
      @adiflied ปีที่แล้ว

      @@ExampleProgram dw, i fixed it the problem was that I was not opening python in edit mode

    • @adiflied
      @adiflied ปีที่แล้ว +1

      @@ExampleProgram Thanks to ur video i did my exam perfectly :)

    • @ExampleProgram
      @ExampleProgram  ปีที่แล้ว

      welcome :)

  • @shama6502
    @shama6502 2 ปีที่แล้ว

    I am litteraly in 8th and I have to learn this shit

    • @nevergonnagiveyouup6477
      @nevergonnagiveyouup6477 2 ปีที่แล้ว

      You are literally in 8th, but still don't know how to spell "Literally"

  • @psychoonit5645
    @psychoonit5645 ปีที่แล้ว

    how to check if a num is positive even and positive odd, negative even and negative odd ( user input ).can u please code me this out? just write in the comment, i will get that.

  • @harshan4744
    @harshan4744 ปีที่แล้ว +1

    🌑

  • @idarksoul
    @idarksoul ปีที่แล้ว

    Tareeka to yrr yahi hai but invalid syntax aarha hai !!

  • @user-il5uq9kn5d
    @user-il5uq9kn5d ปีที่แล้ว +1

    hhhhhhhhhhhheiiiiii suuuuuuuuuppppppppppppppppppppppppperrrrr yyyyyaa

  • @eddienaing6821
    @eddienaing6821 2 ปีที่แล้ว +1

    you can always count on indian guys on youtube

  • @TheVandka
    @TheVandka 3 ปีที่แล้ว

    if 18 get its wrong

  • @sanatani_0011
    @sanatani_0011 2 ปีที่แล้ว +1

    Sir maine ye program run karya. Toh error kyu aaraha h

  • @anonymous_exe__9516
    @anonymous_exe__9516 2 ปีที่แล้ว

    My guy can't differentiate between reminder and remainder.

  • @Satish_0205
    @Satish_0205 ปีที่แล้ว

    Any body single?

  • @Satish_0205
    @Satish_0205 ปีที่แล้ว +1

    Uthke baitho

  • @72saurabhsen73
    @72saurabhsen73 3 ปีที่แล้ว +1

    Thank you

  • @444gamingff7
    @444gamingff7 ปีที่แล้ว +1

    Har Har Mahadev ❤️❤️❤️❤️