Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
prime_nonprime_count.py
def isPrime(n): p=1 if n==1: p=0 else: for i in range(2,n): if n%i==0: p=0 if p==1: return True else: return False def count(lst): prime=0 nprime=0 for e in lst: if isPrime(e): prime+=1 else: nprime+=1 return prime,nprime p,np=count([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]) print('prime_count {} and non prime_count {}'.format(p,np))
run
|
edit
|
history
|
help
0
instance variable class var
Variables.py
Page353ex42
pyFoodTipFoodOrder
shuru9
Assignment-2b
PyCutRod(BotUp)
Rishika
Prac1_2
print