[Tutor] Odds and even exercise

Kelly Netterville 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
> solve?
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
Sorry, didn't use 'reply all' in my initial response. Sending again to
entire list.

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
solve this.

Good luck!
Kelly
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100327/651bf583/attachment.html>


More information about the Tutor mailing list