[Tutor] Python 3.5 installation beside Python 2.3 on Windows 7

2016-10-22 Thread Pierre-Michel Averseng



Le 22/10/2016 à 20:00, tutor-requ...@python.org a écrit :

Python 3.5.2 Installaton Question (niraj pandey)
I already have Python 2.7.1 installed on my laptop. However, I now wish to
switch to Python 3.5.2, which is the latest release. My question is:


Do I have to completely uninstall Python 2.7.1 and then install Python
3.5.2? Or can I still install Python 3.5.2 keeping Python 2.7.1 untouched
on my laptop?
For Windows (including XP, Vista, 7, and 8), Python comes as a 
self-installer MSI
program file—simply double-click on its file icon, and answer Yes or 
Next at every
prompt to perform a default install. The default install includes 
Python’s docu-
mentation set and support for tkinter (Tkinter in Python 2.X) GUIs, 
shelve data-
bases, and the IDLE development GUI. Python 3.3 and 2.7 are normally 
installed

in the directories C:\Python33 and C:\Python27 though this can be changed at
install time.

Best RegardsPierre  Averseng  in South-Western Indian Ocean
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] /tutorial/controlflow.html "break statement"

2013-12-02 Thread Pierre-Michel Averseng

Hello,

what do you think about the results given by IDLE3 with a script studied 
recently in T. Digest Vol 117, issue 70 & seq. ?


I'm working with Linux (Debian family => i.e Linux Mint LMDE :
[please, could you excuse my poor English... ?  Thanks !  ;^))   ]

Linux hojulien 3.10-2-486 #1 Debian 3.10.5-1 (2013-08-07) i686 GNU/Linux
Python 3.3.2+ (default, Aug  4 2013, 17:23:22)
[GCC 4.8.1] on linux

The script studied was :

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 a prime number')

Here is the result given in IDLE3 on my Presario CQ61:

>>> for n in range(2,10):
for x in range(2, n):
if n % x == 0:
print(n, '=',x,'*',n//x)
break
else:
# loop fell through without finding a factor
print(n, 'is a prime number')


3 is a prime number
4 = 2 * 2
5 is a prime number
5 is a prime number
5 is a prime number
6 = 2 * 3
7 is a prime number
7 is a prime number
7 is a prime number
7 is a prime number
7 is a prime number
8 = 2 * 4
9 is a prime number
9 = 3 * 3

I found this script at : 
http://docs.python.org/3/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops




4.4. break
 and
continue

Statements, and else

Clauses on Loops

The break  
statement, like in C, breaks out of the smallest enclosing for 
 or while 
 loop.


Loop statements may have an else clause; it is executed when the loop 
terminates through exhaustion of the list (with for 
) or when 
the condition becomes false (with while 
), but 
not when the loop is terminated by a break 
 
statement. This is exemplified by the following loop, which searches 
for prime numbers:


>>>
>>>  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')
...
2 is a prime number
3 is a prime number
4 equals 2 * 2
5 is a

Surprising !  isn't it ?

Best regards

Pierre
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] /tutorial/controlflow.html Apologies

2013-12-02 Thread Pierre-Michel Averseng

Hmmm,

I beg your pardon !

(Yes, this is the correct code. Look closely: the else clause belongs 
to the for 
 loop, 
*not* the if 
 statement.)


When used with a loop, the else clause has more in common with the 
else clause of a try 
 statement 
than it does that of if 
 
statements: a try 
 
statement’s else clause runs when no exception occurs, and a loop’s 
else clause runs when no break occurs. For more on the try 
 statement 
and exceptions, see /Handling Exceptions/ 
.



Yes the python.org/3/tutorial is good !

Python 3.3 is very different from Python 2 !!

Regards

Pierre
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor