Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

krish013

i m doing lecture 2 now...i have pyhon 2.7.3 with me..when i m writing the if condition i could get until first print but after typing else and pressing enter i m getting a syntax error.please help

  • one year ago
  • one year ago

  • This Question is Closed
  1. jagan
    Best Response
    You've already chosen the best response.
    Medals 1

    I m also getting the same error. But If you use if inside a function, you can avoid getting the syntax error.

    • one year ago
  2. irfans
    Best Response
    You've already chosen the best response.
    Medals 0

    Can you post the code that you have written .

    • one year ago
  3. krish013
    Best Response
    You've already chosen the best response.
    Medals 0

    here it is

    • one year ago
    1 Attachment
  4. krish013
    Best Response
    You've already chosen the best response.
    Medals 0

    jagan,could u be more detailed abt using if inside a function...i dint understand what u said

    • one year ago
  5. jagan
    Best Response
    You've already chosen the best response.
    Medals 1

    in your program else should be below if statement >>> x=15 >>> if (x/2)*2 == x : print 'even' else: print 'odd' Do something like this >>> def test() : x = 15 if (x/2)*2 == x : print 'even' else : print 'odd' >>> test() odd

    • one year ago
  6. jagan
    Best Response
    You've already chosen the best response.
    Medals 1

    you have to maintain the indentation by moving the cursor back and forth using left and right arrow key.

    • one year ago
  7. krish013
    Best Response
    You've already chosen the best response.
    Medals 0

    this is what i got

    • one year ago
    1 Attachment
  8. krish013
    Best Response
    You've already chosen the best response.
    Medals 0

    i still dont get it ...need ur help a lil more

    • one year ago
  9. jagan
    Best Response
    You've already chosen the best response.
    Medals 1

    ok you should do something like this def test() : # after test its not zero its these ( ) braces, press enter after typing this line x = 15 # just type x = 15 if (x/2)* 2 == x : # this line should start from where x variable starts ,press enter print 'even' #press enter else : # when you press enter the your cursor will be below p of print(previous line) move it left by using left arrow key print 'odd' #press enter #press enter again You will get a prompt like >>> type there test() # not zero but ( ) and press enter you will get the output.

    • one year ago
  10. krish013
    Best Response
    You've already chosen the best response.
    Medals 0

    thank u

    • one year ago
  11. ryananthony
    Best Response
    You've already chosen the best response.
    Medals 0

    The course does recommend a particular Python version, 2.5.4 I believe... however, all the 2.X versions are supposed to be backwards compatible with each other

    • one year ago
  12. krish013
    Best Response
    You've already chosen the best response.
    Medals 0

    thank u ryan...i got it

    • one year ago
    • Attachments:

See more questions >>>

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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.