[Tutor] Odds and even exercise
pythelico at gmail.com
Sat Mar 27 14:37:46 CET 2010
On Sat, Mar 27, 2010 at 8:55 AM, TJ Dack <teejmd at gmail.com> wrote:
> Hi, just started python at Uni and think i am in for a rough ride with zero
> prior experience in programming.
> Anyway my problem that i can't fix my self after googling.
> The exercise is to generate a list of odd numbers between 1-100 and the
> same for even numbers.
> So far this is what i have CODE: SELECT ALL<http://python-forum.org/pythonforum/viewtopic.php?f=3&t=17610#> #A
> way to display numbers 1 - 100
> numbers = range(100)
> #A way to display all odd numbers
> odd = numbers[::2]
> #A way to display all even numbers
> I can't find a way to easily list the even numbers, i really need a easier
> way to find answers my self but using the help docs in idle didn't get me
> far, any tips that you guys have when you come across something you can't
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
Sorry, didn't use 'reply all' in my initial response. Sending again to
This is an exercise that is more about thinking programatically than it is
about writing Python code. However, consider that even numbers are evenly
divisible by 2 and odds are not. Now try to use the basics you've learned so
far about Python to solve your problem. A while loop, if, and print
statement along with basic mathematic operators are all you really need to
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor