ps9#2: quick question. for part #2 we have to write addShape to our shape set. My thinking is that I would test with an if statement to verify that the argument passed to the addShape is in fact a valid shape. What's odd is that the program works when I'm limited just to circles. however when I use an if statement with 'or' for circle,square,triangle, I get an error. can anyone explain what's going on? here's the circle example http://codepad.org/LK04Deey here's the circle, square, triangle example where I get a type error. http://codepad.org/T0bXeVGk

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

ps9#2: quick question. for part #2 we have to write addShape to our shape set. My thinking is that I would test with an if statement to verify that the argument passed to the addShape is in fact a valid shape. What's odd is that the program works when I'm limited just to circles. however when I use an if statement with 'or' for circle,square,triangle, I get an error. can anyone explain what's going on? here's the circle example http://codepad.org/LK04Deey here's the circle, square, triangle example where I get a type error. http://codepad.org/T0bXeVGk

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

maybe try the isinstance() function instead - http://docs.python.org/library/functions.html#type
I figured it out. It was kinda obvious. I think if only takes one comparison/equality. You can't use 'or' within the if statement. http://codepad.org/kTzrKgPa
http://dpaste.com/699312/

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

you should be able to use multiple expresions (that evaluate to a boolean) seperated be or or and in an if statement - http://dpaste.com/699316/
ah. I got my equalities screwed up. I need an 'and' statement instead of an 'or' statement. if it's the case that they are all 'not equal', then I don't have a valid shape. Thanks.
or use or with == instead of != http://dpaste.com/699319/
and using isinstance is easier if they are all subclasses of the same class http://dpaste.com/699332/
thanks for all the feedback bwCA. really helps my understanding.

Not the answer you are looking for?

Search for more explanations.

Ask your own question