adam urbas wrote:
Hi,

I just started python today
Great!

One request: provide a meaningful subject when you post questions. That helps us track the various threads.
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 program

print “Welcome to the Area calculation program”
I guess you used a word processor to write the program, and it put in open and close quotes instead of "ordinay" quotes. Change them:

print "Welcome to the Area calculation program"
etc for all other appearances of “ and ”
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”, area
else:
    radius = input(“Please enter the radius: “)
    area = 3.14*(radius**2)
    print “The area is”, area

I'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")
I assume you're running the program by double-clicking. The program window closes as soon as the program stops, so you don't see any output. The input at the end will keep the program window open, but only if execution reaches it (meaning the program has no errors). Since yours has errors, Python displays an exception then terminates so you don't see the exception.

Therefore: it is better to run the program by calling python explicitly. Open a command prompt and enter (for example):
c:\python25\python yourprogram.py (substitute the correct path for python and your program). Then you will see any output. I expect it will be like:

Traceback (  File "yourprogram.py", line 3
    print “Welcome to the Area calculation program”
          ^
SyntaxError: invalid syntax
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
  


-- 
Bob Gailer
510-978-4454


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to