[Tutor] 2 basic problems

Ricardo Aráoz ricaraoz at gmail.com
Sun Jun 16 17:25:56 CEST 2013


El 29/05/13 18:23, charles benoit escribió:
> 1:Python 2.7.4 (default, Apr 19 2013, 18:32:33)
> [GCC 4.7.3] on linux2
> Type "copyright", "credits" or "license()" for more information.
> >>> 4+4
> 8
> >>> 3+3=4
> SyntaxError: can't assign to operator
> >>> 3=1
> SyntaxError: can't assign to literal
> >
> I thought the last 2 lines should return False
>
>
> 2:
> lot=('1'+'6'+'8')
> print(lot)
> a=open("acc","w")
> a.write(lot)
> a.close
> b=open("acc","r")
> b.read()
> print (b)
> b.close
>
>
> returns
> >>>
> 168
> <open file 'acc', mode 'r' at 0xb6f9a650>
> >>>
>
> I thought I was saving a string to a file and reading and printing the 
> string. The output looks like a description of the IO textwrapper at 
> some location. I'm sure this is a syntax/format problem.but this like 
> the other examples I saw. I ran this using python 2.6.7 on ubuntu 
> 13.0  Thank you for any help
>


Python 2.7.3 (default, Aug  1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
==== No Subprocess ====
 >>> 2+2
4
 >>> 4+4
8
 >>> 4+4=6
SyntaxError: can't assign to operator
 >>> 4+4 == 6
False
 >>>




More information about the Tutor mailing list