[docs] The result varies from the desired result as per document

Dosapati, Manikumar manikumar.dosapati at patni.com
Tue Nov 16 04:47:03 CET 2010


Hi Team,
            On running the program given in section 4.4, the actual result is varying from expected and displayed result as shown in the tutorial. Please provide inputs regarding this behavior and suggest where I am going wrong.

The program is


for n in range(2, 10):

...     for x in range(2, n):

...         if n % x == 0:

...             print(n, 'equals', x, '*', n//x)

...             break

...     else:

...         # loop fell through without finding a factor

...         print(n, 'is a prime number')

The displayed or expected result as per tutorial is


2 is a prime number

3 is a prime number

4 equals 2 * 2

5 is a prime number

6 equals 2 * 3

7 is a prime number

8 equals 2 * 4

9 equals 3 * 3

On running the same program getting the result as shown below


>>> for n in range(2,10):
            for x in range(2,n):
                        if n%x ==0:
                                    print(n,'equals',x,'*',n//x)
                                    break
                        else:
                                    print(n,'is aprime number')


3 is aprime number
4 equals 2 * 2
5 is aprime number
5 is aprime number
5 is aprime number
6 equals 2 * 3
7 is aprime number
7 is aprime number
7 is aprime number
7 is aprime number
7 is aprime number
8 equals 2 * 4
9 is aprime number
9 equals 3 * 3
>>>

________________________________
Information contained and transmitted by this e-mail is confidential and proprietary to Patni Computer Systems Ltd and its affiliates (hitherto referred as Patni Computers) and is intended for use only by the recipient. If you are not the intended recipient , you are hereby notified that any dissemination, distribution, copying or use of this e-mail is strictly prohibited and you are requested to delete this e-mail immediately and notify the originator or netadmin at patni.com. Patni Computers does not enter into any agreement with any party by e-mail. Any views expressed by an individual do not necessarily reflect the view of Patni Computers. Patni Computers is not responsible for the consequences of any actions taken on the basis of information provided, through this email. The contents of an attachment to this e-mail may contain software viruses, which could damage your own computer system. While Patni Computers has taken every reasonable precaution to minimise this risk, we cannot accept liability for any damage which you sustain as a result of software viruses. You should carry out your own virus checks before opening an attachment. To know more about Patni Computers please visit www.patni.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20101116/b98b1ad6/attachment.html>


More information about the docs mailing list