Python Program to Check Prime Number - Complete Guide | Python Tutorial

Поделиться
HTML-код
  • Опубликовано: 15 окт 2024
  • In this video, learn Python Program to Check Prime Number - Complete Guide | Python Tutorial. Find all the videos of the 100+ Python Programs Course in this playlist: • Python Program to Add ...
    💎 Get Access to Premium Videos and Live Streams: / @wscubetech
    WsCube Tech is a leading Web, Mobile App & Digital Marketing company, and institute in India.
    We help businesses of all sizes to build their online presence, grow their business, and reach new heights.
    👉For Digital Marketing services (Brand Building, SEO, SMO, PPC, SEM, Content Writing), Web Development and App Development solutions, visit our website: www.wscubetech...
    👉Want to learn new skills and improve existing ones with in-depth and practical sessions? Enroll in our advanced online courses now and make yourself job-ready: courses.wscube...
    All the courses are job-oriented, up-to-date with the latest algorithms and modules, fully practical, and provide you hands-on projects.
    👉 Want to learn and acquire skills in English? Visit WsCube Tech English channel: bit.ly/2M3oYOs
    📞 For more info about the courses, call us: +91-7878985501, +91-9269698122
    ✅ CONNECT WITH THE FOUNDER (Mr. Kushagra Bhatia) -
    👉 Instagram - / kushagrabhatiaofficial
    👉 LinkedIn - / kushagra-bhatia
    Connect with WsCube Tech on social media for the latest offers, promos, job vacancies, and much more:
    ► Subscribe: bit.ly/wscubech...
    ► Facebook: / wscubetech.india
    ► Twitter: / wscubetechindia
    ► Instagram: / wscubetechindia
    ► LinkedIn : / wscubetechindia
    ► RUclips: / wscubetechjodhpur
    ► Website: wscubetech.com
    -------------------------------------| Thanks |--------------------------
    #pythontutorials #python #pythonprogramming

Комментарии • 90

  • @wscubetech
    @wscubetech  2 года назад +3

    😎Hey, thanks for watching! We’d love to know your thoughts/doubts here in the comments.
    👉For professional self-paced certification courses (pre-recorded), visit: bit.ly/Pre-Recorded-Course
    👉Don’t forget to SUBSCRIBE to our channel for more such videos & valuable content: bit.ly/RUclips-WsCubeTech

  • @swamantakmajumder4876
    @swamantakmajumder4876 5 месяцев назад +7

    a=int(input())
    c=0
    for i in range(1,a+1):
    if a%i==0:
    c=c+1
    if(c==2):
    print("Prime number")
    else:
    print("Not prime")

  • @ihaveitinme638
    @ihaveitinme638 10 месяцев назад +9

    def prime_number(n):
    if n==1:
    b=print(n,":not prime")
    return b
    if n>1:
    for i in range(2,n):
    if n%i==0:
    c=print(n,":not prime")
    return c
    break
    else:
    print(n,":prime number")
    n=int(input("enter number:"))
    prime_number(n)

    • @BMWCLASSICS_
      @BMWCLASSICS_ 2 месяца назад

      bro i think in last we also have to put break when i run it on my pc it shows 2 output

  • @Raj-v8j5u
    @Raj-v8j5u Год назад +3

    Thanks mam. Even telusko hadnt explained this topic this superb. It helped me who is from no CS background.

  • @hrishabhbramhe1697
    @hrishabhbramhe1697 4 месяца назад +3

    x = 4
    if x ==1:
    print('not a prime')
    elif x ==2:
    print('prime')
    elif x>2:
    for i in range(2,x):
    if x%i == 0:
    print('not prime')
    break
    else:
    print('prime')
    break

  • @sakshimourya5418
    @sakshimourya5418 Год назад +6

    you deserve more likes, cleared my concept completely.

  • @VARADHARLIKAR-ul1oc
    @VARADHARLIKAR-ul1oc 3 месяца назад

    def prime_number(n):
    if n==1:
    b=print(n,"is not an prime number")
    return b
    if n>1:
    for i in range(2,n):
    if n%i==0:
    c=print(n,"is not an prime number")
    return c
    break
    else:
    print(n,"is prime number")
    n=int(input("enter the number to check :"))
    prime_number(n)

  • @00__mdasif
    @00__mdasif 2 года назад +2

    We wanna deep sir python videos please upload plz....

  • @oxivrushab2573
    @oxivrushab2573 Год назад

    Can we use only in if condition using or like number which divides by 2,3,4,5,7,6,8,9,11 are not prime else are prime my work effectively

  • @GoGetSP
    @GoGetSP 2 месяца назад

    num=int(input("Enter a num to check whether prime or not:"))
    if num == 1:
    print(num,"is not a prime number.")
    elif num == 2:
    print(num,"is the smallest prime number.")
    else:
    for i in range(2,num):
    if num % i ==0:
    print(num," is not a prime number.")
    else:
    print(num,"is a prime number.")
    break

  • @tabariqawabullah0626
    @tabariqawabullah0626 Год назад +3

    Great video. But This code is saying 9,15,21... are prime numbers but they are not. Any idea why?

    • @madiripadma3877
      @madiripadma3877 Год назад

      Prime number means the number divisible by 1 and itself.for eg : 5
      5 is divisible by 1 and 5 only so it is prime number.

    • @AdityaThakur-cq1ov
      @AdityaThakur-cq1ov Год назад

      I think something wrong with this code....
      it's say 49 is prime .....kese......

    • @karthikchinna3621
      @karthikchinna3621 10 месяцев назад

      You need to add break statment

  • @statusvideo2701
    @statusvideo2701 Год назад

    Which platform(application) maam is using to run python code ...
    Please someone reply...

  • @anud1917
    @anud1917 Год назад +7

    # 11:program to check if any given number is a prime number.
    num = int(input("enter the number"))
    if num

    • @sapisgreat
      @sapisgreat 8 месяцев назад

      doesnt work with 0

    • @asishkumarpatro5903
      @asishkumarpatro5903 6 месяцев назад

      ​@@sapisgreatwill work bhai

    • @sapisgreat
      @sapisgreat 6 месяцев назад

      @@asishkumarpatro5903 didnt for me

    • @I.agri.
      @I.agri. Месяц назад

      @@sapisgreat that's because 0 is neither a prime nor a composite.

  • @itsonlytech8251
    @itsonlytech8251 2 года назад +2

    Nice Information

  • @gauravpandey9739
    @gauravpandey9739 7 месяцев назад

    You are amazing mam❤

  • @shubham_gaming-i2v
    @shubham_gaming-i2v Год назад +1

    num=int (input("enter the number"))
    if num==1:
    print("not prime")
    for a in range(2,num):
    if num%a==0:
    print("it not a prime number")
    break
    else:
    print("prime number")

    • @SummiyaDiyar
      @SummiyaDiyar 8 месяцев назад

      here you miss another if condition

  • @prittamsingh4453
    @prittamsingh4453 Год назад

    mam which software you are using

  • @sushantchougale6818
    @sushantchougale6818 2 года назад +1

    Thank you very much 😊 ☺️

  • @Anubhav_Sh_
    @Anubhav_Sh_ 8 месяцев назад

    very helpful playlist.

  • @oxivrushab2573
    @oxivrushab2573 Год назад

    num=float(input(" enter the number "))
    if(num%2==0)or(num%3==0)or(num%4==0)or(num%5==0)or(num%6==0)or(num%7==0)or(num%8==0)or(num%9==0)or(num%11==0):
    print( " number is not prime")
    else:
    print(" the numver is prime")

    • @Mr.Regaltos
      @Mr.Regaltos 11 месяцев назад

      it will say 13 is not prime
      wrong

    • @asishkumarpatro5903
      @asishkumarpatro5903 6 месяцев назад

      Bhai infinite prime h tu aise nahi kar sakta

  • @niraj_cn
    @niraj_cn 2 года назад +2

    Nice video

  • @abhijeetsinghyadav8988
    @abhijeetsinghyadav8988 6 месяцев назад

    n= int(input("Enter any number: "))
    if (n%n==0) and (n%2!=0) and (n>1):
    print("Given number is a prime ")
    else:
    print("No is not a prime ")

    • @akashrai5253
      @akashrai5253 5 месяцев назад +1

      This same condition is apply to many numbers like 15 when it is divided by 2 it will not return 0 but it is not a prime number, so this condition will not work even mam's condition is also not working.

  • @sohebsk2196
    @sohebsk2196 Год назад +2

    this code does not hold for some numbers,,,here isthe correct version:
    n=int(input("ENTER A NUMBER="))
    if n

  • @kabeersharma6403
    @kabeersharma6403 Год назад

    Thanku Thanku Thanku Thanku

  • @naresh9675
    @naresh9675 2 года назад +1

    Grateful

  • @gtdforum
    @gtdforum Год назад

    Is there a need for a for loop in this example

  • @ronak-myself
    @ronak-myself Год назад +1

    Sb samajh agya

  • @bobbyrajgorai695
    @bobbyrajgorai695 Год назад

    we can use this also;
    x=float(input('enter the year'))
    if (x+1)/2%2==0 :
    print ( ' the no. is prime')
    else:
    print (' the no. is not prime')

  • @sahildash7222
    @sahildash7222 Год назад

    num=13
    fcount=0
    for f in range(1,num+1):
    if(num%f==0):
    fcount=fcount=1
    if(fcount==0):
    print('It is a prime number')
    else:
    print('not a prime number')

  • @impavel323
    @impavel323 2 месяца назад

    a= ("Thank You Mam")
    Print(a)

  • @comingsoon..4258
    @comingsoon..4258 7 месяцев назад +3

    computer science students attendance here

    • @Bunty759
      @Bunty759 4 месяца назад

      Present sir

  • @itzmasum1079
    @itzmasum1079 2 года назад +1

    With this code please try input "2"

    • @Aditya_Deshmukh
      @Aditya_Deshmukh Год назад +2

      x =int(input("Enter Your Number Please: "))
      if x == 2:
      print("A Prime Number.")
      else:
      for i in range(2,x):
      if x % i == 0:
      print("Not a Prime Number.")
      break
      else:
      print("A Prime Number.")

  • @bgmiviralshort
    @bgmiviralshort 2 года назад

    Good

  • @raosajid6578
    @raosajid6578 2 года назад +1

    9 is does not satisfy your code if user enter 9 then it will give us it is prime but it is not

    • @rohitraj7914
      @rohitraj7914 11 месяцев назад +2

      9 jb enter krenge to num=9 ho jayega to loop 2-8 tk hi chlega. So condition is satisfying for 9 also.

    • @asishkumarpatro5903
      @asishkumarpatro5903 6 месяцев назад

      ​@@rohitraj7914no brother 9 divisible by 3 so it doesn't work

  • @cnadegameplay8031
    @cnadegameplay8031 4 месяца назад

    hey, check 43 as input.

  • @turyachaitanya
    @turyachaitanya Год назад

    num = int(input("Enter a number
    "))
    if num < 2:
    print("Enter a number")
    elif num == 2:
    print(" 2 is a prime number")
    else:
    for i in range(2,num):
    if num%i ==0:
    print(num,"is not a prime number")
    break
    else:
    print(num,"is a prime number")

    • @shubham_gaming-i2v
      @shubham_gaming-i2v Год назад

      @turyachaitanya
      if num < 2:
      print("Enter a number")
      elif num == 2:
      print(" 2 is a prime number") ye vala part ka use kya tha jab 2 se num tak spicify kar rahe hai tu

    • @turyachaitanya
      @turyachaitanya Год назад +1

      @@shubham_gaming-i2v 2%2 is 0, it will say not prime, but 2 is prime. So a line is written for 2.

  • @manjari400
    @manjari400 Год назад +18

    This code is not working appropriately for 2 and the odd numbers that are non prime number like 15,21,9 etc.

    • @AshishVerma13yq
      @AshishVerma13yq 8 месяцев назад +2

      Same doubt

    • @Staredits006
      @Staredits006 7 месяцев назад +1

      Same

    • @badalmishra7395
      @badalmishra7395 6 месяцев назад

      It is working fine. I think the problem you got is with "else" . You need to shift it as she said backwards

    • @asishkumarpatro5903
      @asishkumarpatro5903 6 месяцев назад

      ​@@badalmishra7395but shouldn't if and else statements be in the same indentation?

    • @badalmishra7395
      @badalmishra7395 6 месяцев назад

      @@asishkumarpatro5903 yes correct. But in this case if you use the same indentation as "if" in the for loop, it will throw "it is a prime number " multiple time , to break that loop for the output printed once, we need to get that else out of that for loop indentation or use the same indentation used for "for loop" statement. Secondly else should be the same indentation as "if" -True , but , here we have 3 ifs', and the code determines what should be the indentation of else. That's how loop function works

  • @Aditya_Deshmukh
    @Aditya_Deshmukh Год назад +1

    x =int(input("Enter Your Number Please: "))
    if x == 2:
    print("A Prime Number.")
    else:
    for i in range(2,x):
    if x % i == 0:
    print("Not a Prime Number.")
    break
    else:
    print("A Prime Number.")

  • @DataEngineer586
    @DataEngineer586 Год назад

    n= int(input("Enter any number: "))
    if (n%n==0 and n%2!=0 and n>1):
    print("Given number is a prime ")
    else:
    print("No is not a prime ")
    # please let me know if this method is wrong of writing code

  • @gamingstudyff9525
    @gamingstudyff9525 2 года назад

    Hello sir
    I am a school student .
    Sir mai athichal hacking sikhna chahta hu plz mere ko batai ki
    Whete to star

    • @AdityaThakur-cq1ov
      @AdityaThakur-cq1ov Год назад +1

      Abhi se phle where ki spelling thik kro fir agge dekhte h

  • @rishiraj2548
    @rishiraj2548 Год назад

    print("Prime Number Check")
    num = int(input("Enter a number to check: "))
    status = "prime"
    if num

  • @rameezraja2489
    @rameezraja2489 10 месяцев назад

    Simple program ko itna complex kyu bana Diya aapne ek hi condition lagega if num%==0 then print non prime number then else num%==1 then print....... whatever you want to print

  • @wannabe_gamer1230
    @wannabe_gamer1230 4 месяца назад

    How about 2?

  • @Abhinavmittal00
    @Abhinavmittal00 5 месяцев назад

    667 is not a prime no. and not divisible by any no. from 2to 10

  • @ShubhamSharma-od6tf
    @ShubhamSharma-od6tf 20 дней назад

    Wrong code ❌ , as number is only being checked by dividing it by 2 .

  • @premgautam4957
    @premgautam4957 2 года назад

    Please help me sir

  • @dhaHu
    @dhaHu 10 месяцев назад

    People starting in English and later changing their language 🙂but y

  • @saritashukla123
    @saritashukla123 6 месяцев назад

    This code is not right.

    • @VineelDikkala
      @VineelDikkala 3 месяца назад

      Why bro??

    • @someshbiswas119
      @someshbiswas119 3 месяца назад

      @@VineelDikkala because 93 is not a prime number but this code shows it is a prime number

  • @sunnyyadav1298
    @sunnyyadav1298 Месяц назад

    Didi nhi ho paya tumse rehne do

  • @khushiv2003
    @khushiv2003 Год назад +6

    n=int(input())
    if n==1:
    print('n is not prime')
    elif n==2:
    print('n is prime')
    else:
    for i in range(2,n):
    if n%i==0:
    print('n is not prime')
    break
    else:
    print('n is prime')

    • @rushijadhav6903
      @rushijadhav6903 3 месяца назад

      What about 99,15,21,25 they are not prime number

  • @turyachaitanya
    @turyachaitanya Год назад

    Another metho
    num = int(input("Enter a number
    "))
    count = 0
    if num>1:
    for i in range(1,num+1):
    if (num%i) == 0:
    count =count+1
    if count == 2:
    print(num,"is a prime number")
    else:
    print(num,"is not a prime number")