Description: This in-class question explains what mathematical statements are and are not valid in python.
Instructor: Dr. Ana Bell
The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To make a donation or view additional materials from hundreds of MIT courses, visit MIT OpenCourseWare at ocw.mit.edu.
ANA BELL: So this next exercise is which of the following is allowed in Python. So x plus y is equal to 2. And again, these are all things that you can just type into Anaconda, which is our IDE for the class, and see whether it works or not.
So this-- the first one is probably not right-- let's increase it a little bit-- is not right because the left side needs to be a variable. This is not right because it's an expression. This is not right because 2 is not a proper variable name. And xy-- that one's actually going to be OK because it's not multiplication, it's just the variable xy. So 50% said xy is equal to 2, and that's right.
So none of these. So just to make sure that you guys understand, xy, this last one here, is the right one because xy is not x times y, like in math. It's just one variable name that has two characters, x and y.