anonymous
  • anonymous
Hi i am having difficulty in doing even and odd in lecture (1) looks weird i am getting a syntax error all the time. Please help.
MIT 6.00 Intro Computer Science (OCW)
schrodinger
  • schrodinger
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

anonymous
  • anonymous
>>> x = 15 >>> if (x/2)*2 ==x: print "even" SyntaxError: invalid syntax
anonymous
  • anonymous
Havent taken a look at it yet, but it looks like you are missing a bunch of variables. What is "even"? Is that all of your source code?
anonymous
  • anonymous
it didn't give me space to write the else code. It stopped at that level.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
write your code on a text document and attach it :)
anonymous
  • anonymous
I am doing some trials but not as in lecture (1) don't know why.
1 Attachment
anonymous
  • anonymous
It is invalid syntax because your "wording" did not make sense to python- This statement- [if (x/2)*2 ==x:] is fine, but [if (x/2)*2 =x:] is not because "=" assigns a value and does not "equate"
anonymous
  • anonymous
ok but why the result was 15 an even number ?
anonymous
  • anonymous
because 15/2 = 7.5 and 7.5*2 = 15
anonymous
  • anonymous
not the best way to test for even/odd number. On the other hand "%" works really well (which you did )
anonymous
  • anonymous
yes...Thanks a lot. Not used yet to " " and ( ) and this is giving me hard times but its fun. Thanks a lot again for helping me.
anonymous
  • anonymous
You are welcome :) I apologize for the improper use of tokens ( " ", [ ] ), but I am glad I was able to help.

Looking for something else?

Not the answer you are looking for? Search for more explanations.