A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 5 years ago
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.
anonymous
 5 years ago
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.

This Question is Closed

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0>>> x = 15 >>> if (x/2)*2 ==x: print "even" SyntaxError: invalid syntax

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Havent 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
 5 years ago
Best ResponseYou've already chosen the best response.0it didn't give me space to write the else code. It stopped at that level.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0write your code on a text document and attach it :)

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0I am doing some trials but not as in lecture (1) don't know why.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0It 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
 5 years ago
Best ResponseYou've already chosen the best response.0ok but why the result was 15 an even number ?

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0because 15/2 = 7.5 and 7.5*2 = 15

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0not the best way to test for even/odd number. On the other hand "%" works really well (which you did )

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0yes...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
 5 years ago
Best ResponseYou've already chosen the best response.0You are welcome :) I apologize for the improper use of tokens ( " ", [ ] ), but I am glad I was able to help.
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.