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
😎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
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")
I did this...but this is nt working 😭annnnnn
@@Lotus_TheGirlish it is working bro lol
@@sumaiya_730 ok
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)
bro i think in last we also have to put break when i run it on my pc it shows 2 output
Thanks mam. Even telusko hadnt explained this topic this superb. It helped me who is from no CS background.
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
It's wrong, try 17
you deserve more likes, cleared my concept completely.
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)
We wanna deep sir python videos please upload plz....
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
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
Great video. But This code is saying 9,15,21... are prime numbers but they are not. Any idea why?
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.
I think something wrong with this code....
it's say 49 is prime .....kese......
You need to add break statment
Which platform(application) maam is using to run python code ...
Please someone reply...
pi charm
# 11:program to check if any given number is a prime number.
num = int(input("enter the number"))
if num
doesnt work with 0
@@sapisgreatwill work bhai
@@asishkumarpatro5903 didnt for me
@@sapisgreat that's because 0 is neither a prime nor a composite.
Nice Information
You are amazing mam❤
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")
here you miss another if condition
mam which software you are using
pycharm
Thank you very much 😊 ☺️
very helpful playlist.
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")
it will say 13 is not prime
wrong
Bhai infinite prime h tu aise nahi kar sakta
Nice video
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 ")
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.
this code does not hold for some numbers,,,here isthe correct version:
n=int(input("ENTER A NUMBER="))
if n
2 is prime brother
Thanku Thanku Thanku Thanku
Grateful
Is there a need for a for loop in this example
Sb samajh agya
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')
Not effective bro👍🏻
For 27
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')
a= ("Thank You Mam")
Print(a)
computer science students attendance here
Present sir
With this code please try input "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.")
Good
9 is does not satisfy your code if user enter 9 then it will give us it is prime but it is not
9 jb enter krenge to num=9 ho jayega to loop 2-8 tk hi chlega. So condition is satisfying for 9 also.
@@rohitraj7914no brother 9 divisible by 3 so it doesn't work
hey, check 43 as input.
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")
@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
@@shubham_gaming-i2v 2%2 is 0, it will say not prime, but 2 is prime. So a line is written for 2.
This code is not working appropriately for 2 and the odd numbers that are non prime number like 15,21,9 etc.
Same doubt
Same
It is working fine. I think the problem you got is with "else" . You need to shift it as she said backwards
@@badalmishra7395but shouldn't if and else statements be in the same indentation?
@@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
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.")
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
Your code is wrong bro
Hello sir
I am a school student .
Sir mai athichal hacking sikhna chahta hu plz mere ko batai ki
Whete to star
Abhi se phle where ki spelling thik kro fir agge dekhte h
print("Prime Number Check")
num = int(input("Enter a number to check: "))
status = "prime"
if num
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
How about 2?
667 is not a prime no. and not divisible by any no. from 2to 10
Wrong code ❌ , as number is only being checked by dividing it by 2 .
Please help me sir
People starting in English and later changing their language 🙂but y
This code is not right.
Why bro??
@@VineelDikkala because 93 is not a prime number but this code shows it is a prime number
Didi nhi ho paya tumse rehne do
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')
What about 99,15,21,25 they are not prime number
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")
Won't work 1 se sabka remainder 0 aayega