![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
def even(number): if int(number)/2 == int: print "1" else: print "0"
| Try using the mod function, %, it will work much easier.-poof #10 |
| No. I think you switched your 1s and 0s.-Charlie Holder |
| Filter returns the ones that are true. Are 4 6 8 9 and 10 prime numbers? - |
| So, you can look at the definition of a prime number in two ways. 1) a prime number is only divisble by 1 and itself. So 1 would be prime because it satisfies that; 2) a prime numbers has exactly 2 divisors. Since 1 doesn't satisfy that it would not be prime. You can make your own decision. - |
| Much better :)Larry Olson |
def isEven(num):
if num%2 == 0:
return 1
else:
return 0
def isOdd(num):
if num%2 == 1:
return 1
else:
return 0