On Tue, Sep 28, 2010 at 12:15 AM, masawudu bature <mass0...@yahoo.ca> wrote: > I'm having a hard time finding the count of divisors that are even. Help > anybody? > > Here's my code. > > The output is suppose to count the number of even divisors the range has. > > def evenCount(b) : > for n in range(x, y+1) : > count = 0 > if n % 2 == 0 : > count += n/3 > count % n == 1 > return n > > > ### main #### > > x = input("Enter a starting value: ") > y = input("Enter a stopping value: ") > > count = evenCount(x) > > for n in range(x, y+1) : > count = 0 > if n % 2 == 0 : > count += n/3 > print "%2d: " %n, "has%2d" %count, "even divisors", > else : > print "%2d: " %n, "has 0 even divisors", > print > > > > _______________________________________________ > Tutor maillist - tu...@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > >
#You start with your range variables x = input("Enter a starting value: ") y = input("Enter a stopping value: ") #You set a for loop for range for num in range(x, y): #If that number divided by 2 has a remainder of 0, it's of course even. if num % 2 == 0: #print the number print num And various other ways as well. David _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor