Thanks David, But the loop was suppose to produce the count of even divisors an integer has. Like, 6 has 2 "even" divisors, which is 2 and 6, itself. 8 = 3 even divisors, which is 2, 4 ,and 8 10 = 2 even divisors, which is 2, and 10 12 = 4 even divisors, which is 2, 4, 6, and 12
sorry, I just don't know how to write a code to count the number of divisors ________________________________ From: David Hutto <smokefl...@gmail.com> To: masawudu bature <mass0...@yahoo.ca> Cc: tutor@python.org Sent: Mon, September 27, 2010 11:36:05 PM Subject: Re: [Tutor] Python Help 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 - Tutor@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