[Tutor] how do I set variables in Python 3.4
Danny Yoo
dyoo at hashcollision.org
Fri Jul 11 21:42:49 CEST 2014
> I am supposed to use operand1=2 and operand2=7
> To complete: result= operand1+operand2 etc, but I keep getting invalid syntax either on the " or operand1. Please help
Unfortunately, you've paraphrased the error message enough that we can
not reproduce the problem. Since you're emailing on your phone, you
may want to reply when you're in front of your compute and are in a
position to do some copy-and-pasting.
Please copy and paste exactly what your entire program looks like.
Please copy and paste the exact contents of the error message and the
surrounding lines. Also, please say what you expected your program to
do.
For example, let's pretend that I'm seeing a problem in my own
program. Here's how I'd ask for help:
---------------------------------------------------------------------------------------
I'm seeing the following error in my program:
>>> percent(1, 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in percent
ZeroDivisionError: integer division or modulo by zero
Here is my program:
#######################
def percent(part, whole):
return part / whole
#######################
I expected to see infinity here, but I'm seeing this error instead.
Can you help explain what I can do to get this value?
---------------------------------------------------------------------------------------
That is, show the error message, show the program content, and most
importantly, try to say what you expected to see.
It may be obvious to you what should happen, but sometimes it isn't
obvious! Here, in this example, I'm pretending to be a crazy person
who believes in infinity. :P And that information is useful, because
there actually is a way of getting such a value:
http://stackoverflow.com/questions/7781260/how-can-i-represent-an-infinite-number-in-python.
If I left that part out, the answers I get from other people might be
entirely different or miss this possibility altogether.
Good luck to you.
More information about the Tutor
mailing list