[Tutor] need help with conditionals

christopher.henk at allisontransmission.com christopher.henk at allisontransmission.com
Fri Sep 25 23:39:50 CEST 2009


> Hello all, 
> I am still very new to Python and am working on conditionals. Im stuck 
on this 
> problem and I'm sorry if this is something really simple that I'm 
missing but its 
> been really frustrating me. Here's a copy of the problem, and sorry if 
its really 
> long but its the end question about the logically equivalent expressions 
I'm 
> stuck on. Anyways, heres a copy of the problem
> 
> -----------------------------------------------------------
> 


> >>> from p_and_q import *
> >>> truth_table("p or q")


Are you calling the function as shown above?



> 
> Whenever I try to enter the expressions listed into the prompt it tells 
me the 
> string object is not callable....


It would be helpful if you showed us exactly what you type into the prompt 
and the exact error you get.  You should be calling the function as it is 
shown in the problem.
Assuming the function is entered and imported correctly you should get a 
true table output.

two examples:
>>> truth_table("p or q")
 p      q      p or q
=====================
True    True    True
True    False   True
False   True    True
False   False   False
>>> truth_table("not(p or q)")
 p      q      not(p or q)
==========================
True    True    False
True    False   False
False   True    False
False   False   True

Without a bit more info its hard to guess what is happening.

Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090925/e1542143/attachment.htm>


More information about the Tutor mailing list