new guy

Discussion in 'Python' started by nards_collective, Nov 18, 2003.

  1. I'm new to Python, in fact I'm new to programming. I'm trying to write
    a simulation program, for a biology class I'm teaching next year. the
    following code is giving me trouble and i can't work out why.

    if e>= 1 :
    a=e
    else :
    a=0


    I keep getting a syntax error.
    This piece of code is meant to keep the value of a equal to or grater
    than 0. Any odeas would be appreciated.

    THAnkS
    NArDS
     
    nards_collective, Nov 18, 2003
    #1
    1. Advertising

  2. nards_collective

    KefX Guest

    > if e>= 1 :
    > a=e
    > else :
    > a=0
    >I keep getting a syntax error.


    You sure this causes it? It doesn't seem to be great style to me (should be no
    space before a colon, spaces around the equals sign, space before the >=
    operator), but that won't cause a syntax error.

    What is the exact error message you receive? Even better, post the whole
    traceback.

    - Kef
     
    KefX, Nov 18, 2003
    #2
    1. Advertising

  3. In article <>,
    nards_collective <> wrote:
    >I'm new to Python, in fact I'm new to programming. I'm trying to write
    >a simulation program, for a biology class I'm teaching next year. the
    >following code is giving me trouble and i can't work out why.
    >
    > if e>= 1 :
    > a=e
    > else :
    > a=0
    >
    >
    >I keep getting a syntax error.
    >This piece of code is meant to keep the value of a equal to or grater
    >than 0. Any odeas would be appreciated.

    .
    .
    .
    Others have already spoken to the details of syntax.
    The best help I can give is to recommend you read
    <URL: http://www.catb.org/~esr/faqs/smart-questions.html >.
    Also, although it's nominally about a different language,
    you might like <URL: http://wiki.tcl.tk/RequestHelp >.

    Being "new to programming" is exciting! You'll accelerate
    your progress as you develop an instinct to change
    I keep getting a syntax error
    to
    I see the specific syntax error, '...'
    [copied EXACTLY from the screen].

    Python has a lot to offer, and already has many successes
    in, biology and other physical sciences. Some day the
    references in <URL: http://
    phaseit.net/claird/comp.programming/open_source_science.html >
    might interest you.
    --

    Cameron Laird <>
    Business: http://www.Phaseit.net
     
    Cameron Laird, Nov 18, 2003
    #3
  4. nards_collective

    Ron Adam Guest

    On Tue, 18 Nov 2003 12:03:50 -0000, "nards_collective"
    <> wrote:

    >I'm new to Python, in fact I'm new to programming. I'm trying to write
    >a simulation program, for a biology class I'm teaching next year. the
    >following code is giving me trouble and i can't work out why.
    >
    > if e>= 1 :
    > a=e
    > else :
    > a=0
    >
    >
    >I keep getting a syntax error.
    >This piece of code is meant to keep the value of a equal to or grater
    >than 0. Any odeas would be appreciated.
    >
    >THAnkS
    >NArDS
    >
    >


    1. Check that you didn't type "If" instead of 'if', or "Else"
    instead of "else".

    2. Look at the line above the if statement, it may be the actual line
    with the error in it. Tt may be missing a ending quote, bracket, or
    parentheses, or be incomplete in some other way.


    _Ronald Adam
     
    Ron Adam, Nov 18, 2003
    #4
  5. nards_collective

    Peder Ydalus Guest

    ....and remember to declare the e somewhere above the snippet to avoid a
    NameError...

    - Peder -
     
    Peder Ydalus, Nov 20, 2003
    #5
  6. nards_collective

    Mark Roach Guest

    On Tue, 18 Nov 2003 12:03:50 +0000, nards_collective wrote:

    > if e>= 1 :
    > a=e
    > else :
    > a=0
    >
    >
    > I keep getting a syntax error.
    > This piece of code is meant to keep the value of a equal to or grater
    > than 0. Any odeas would be appreciated.


    you could also use a = max(0, e)

    -Mark
     
    Mark Roach, Nov 23, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VG9t?=

    new guy needs some help

    =?Utf-8?B?VG9t?=, May 25, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    320
    =?Utf-8?B?RGVtZXRyaQ==?=
    May 25, 2006
  2. tom c
    Replies:
    2
    Views:
    541
    Rick Strahl
    Jul 9, 2006
  3. Replies:
    2
    Views:
    523
  4. Macon Joe Job Guy Joe Macon Job Guy

    Att: Macon Joe Job Guy Joe Macon Job Guy Macon

    Macon Joe Job Guy Joe Macon Job Guy, Oct 14, 2007, in forum: Java
    Replies:
    0
    Views:
    394
    Macon Joe Job Guy Joe Macon Job Guy
    Oct 14, 2007
  5. Replies:
    1
    Views:
    235
    Rectal Mania
    Aug 6, 2007
Loading...

Share This Page