[Tutor] (no subject)

Rolando Pereira finalyugi at sapo.pt
Sat May 12 19:55:20 CEST 2007

adam urbas escreveu:
> Hi,I just started python today and I would like a few pointers, if you don't mind.  I tried using a tutorial, but was only able to get the correct results for the most basic problems.  # Area calculation programprint “Welcome to the Area calculation program”print “–––––––––––––”print# Print out the menu:print “Please select a shape:”print “1  Rectangle”print “2  Circle”# Get the user’s choice:shape = input(“> “)# Calculate the area:if shape == 1:    height = input(“Please enter the height: “)    width = input(“Please enter the width: “)    area = height*width    print “The area is”, areaelse:    radius = input(“Please enter the radius: “)    area = 3.14*(radius**2)    print “The area is”, areaI've been trying to get this to work.  I was on a forum on Google and they said to put:input("press ENTER to continue")at the end.  I did, but it didn't work.  It runs the program but just shuts itself off when its done and i don't even get to select any of the option things that i'm s
upposed to be able to select.  It just turns on then back off and I don't even get to see anything.  Could someone help me out.ThanksAdam
> _________________________________________________________________
> Create the ultimate e-mail address book. Import your contacts to Windows Live Hotmail.
> www.windowslive-hotmail.com/learnmore/managemail2.html?locale=en-us&ocid=TXT_TAGLM_HMWL_reten_impcont_0507
> ------------------------------------------------------------------------
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

First, welcome to the world of Python. :D
Second. please give a title when you start a new thread on a mailing list.
Third, format your posts and code. Since Python uses indented code, it's 
kinda hard to read it when it's all in one line (Don't worry, I'll paste 
it indented in a file attached to this email :D )

Now for the code.

After arranging the code, the first thing I noticed were this characters “ ”

I tried running the code, and if gave me a error there, so I just 
replace then with " ", and voilá, the code worked :D . So the lesson 
here is always use either " " or ' ' in the code.

Oh, also another thing. Don't use input() to get the user input, because 
that command can run code and it may be evilly used. Always use 
raw_input() instead :D .

Anyway, I hope I helped you,

ASCII ribbon campaign ( )
  - against HTML email  X
              & vCards / \
-------------- next part --------------
A non-text attachment was scrubbed...
Name: teste.py
Type: text/x-python
Size: 588 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20070512/7e7596a6/attachment-0001.py 

More information about the Tutor mailing list