question

2011-08-14 Thread Abhishek Jain
Hello all,

I wrote a python program to find the 1000th prime no. The program isn't
working as it should be.
Please tell what the error is:

## this is to find the 1000th prime number

number = 3
while number < 1:
###initialize stuff
counter = 1
###initializing list to check primarity
factor = []
while counter!=(number/2):
if number % counter == 0:
factor = factor + [counter]
counter = counter + 1
if len(factor) > 1:
break
elif counter == 1000:
print number,
number+=1



The program is printing all the prime nos. from 1009 to 9973. Please respond
fast and give me the correct code with only simple functions as i am a
beginner to python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Equality check

2011-08-03 Thread Abhishek Jain
How to check equality of two nos. in python
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How would I write this C code in Python?

2007-07-07 Thread Abhishek Jain

how would MAXBUFFERSIZE be taken care in python;

--abhi

On 7/7/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote:


On Fri, 06 Jul 2007 17:31:50 +, DeveloperX wrote:

> Python Attempt: Please note that since I can't type TABs online
> easily, I am using the @ character to represent TABs in the following
> Python code.

Why not indent with spaces, just like you did for the example C code?


--
Steven.


--
http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: list.append not working?

2007-07-05 Thread Abhishek Jain

with every iteration your previous values are overwritten ('md' is a
dictionary) so thats why your are observing this ouput..

check  if the following patch solves your problem

for entity in temp:
   md['module']= entity.addr.get('module')
   md['id']=entity.addr.get('id')
   md['type']=entity.addr.get('type')
   #print md
   mbusentities.append(md)
   md = {}
   #print mbusentities


Regards
Abhi




On 7/5/07, Hardy <[EMAIL PROTECTED]> wrote:


I experience a problem with append(). This is a part of my code:

for entity in temp:
md['module']= entity.addr.get('module')
md['id']=entity.addr.get('id')
md['type']=entity.addr.get('type')
#print md
mbusentities.append(md)
#print mbusentities

I want something like: [{'module': 'home', 'id': 123, 'type': 'core'},
{'module': 'work', 'id': 456, 'type': 'core'}]
md is always correct, BUT:mbusentities is wrong. Length of
mbusentities is same of temp, so it appended everything. BUT:
mbusentities only shows the values of the last append: [{'module':
'work', 'id': 456, 'type': 'core'}, {'module': 'work', 'id': 456,
'type': 'core'}]

What's wrong?

--
http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list