[Tutor] First program

2010-03-12 Thread yd
Hi, I am new to programming, altough i have read a few books about OOP and O'Reily's Learning Python. I would like some critique on my first program, is it normal for it to be this long to do something simple? I know i could have turned some of these things into classes and functions but i don't kn

Re: [Tutor] First program

2010-03-13 Thread yd
Thanks everyone, I am trying to figure out functions and classes right now, i will probably rewrite the program once i get that down and probably use try: and except: for error catching. ___ Tutor maillist - Tutor@python.org To unsubscribe or change sub

[Tutor] Prime numbers

2010-03-27 Thread yd
Having a problem finding the first 1000 prime numbers, here is my code:- print(2) n =3 counter =1 while counter <=1000: for x in range(3,int((n**0.5)),2): if n%x != 0: print(n) n+=1 counter+=1 else: n+=1 The problem is, it prints 2 and then does nothing, yet if i

Re: [Tutor] Odds and even exercise

2010-03-27 Thread yd
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

Re: [Tutor] Prime numbers

2010-03-28 Thread yd
> > > > What 'problem' are you trying to solve? > In general, anytime you can use a premade solution, you are at an > advantage, > not cheating. > That's one of the marks of a truly good programmer - being able to reuse as > much code as possible. > Unless it's a homework problem and he said "don't