% operation

Discussion in 'Python' started by Daewon YOON, Jan 5, 2005.

  1. Daewon YOON

    Daewon YOON Guest

    ====
    Python 1.5.2 (#1, Jul 5 2001, 03:02:19) [GCC 2.96 20000731 (Red Hat
    Linux 7.1 2 on linux-i386
    Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
    >>> x=9
    >>> y=4
    >>> x%y

    1
    >>> for z in range(44):

    .... z%9
    File "<stdin>", line 2
    z%9
    ^
    SyntaxError: invalid syntax

    ====
    What's wrong with the above operation and how can I get the correct
    modulo result with Python?

    --
    ZOO-<
     
    Daewon YOON, Jan 5, 2005
    #1
    1. Advertisements

  2. On Wed, 05 Jan 2005 15:36:30 +0900, Daewon YOON wrote:

    > ====
    > Python 1.5.2 (#1, Jul 5 2001, 03:02:19) [GCC 2.96 20000731 (Red Hat
    > Linux 7.1 2 on linux-i386
    > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
    > >>> x=9
    > >>> y=4
    > >>> x%y

    > 1
    > >>> for z in range(44):

    > ... z%9
    > File "<stdin>", line 2
    > z%9
    > ^
    > SyntaxError: invalid syntax
    >
    > ====
    > What's wrong with the above operation and how can I get the correct
    > modulo result with Python?


    There's nothing wrong with the operation, but it looks like you forgot to
    indent your loop body (which the interactive shell doesn't automagically
    do for you):

    >>> for z in range(44):

    .... z%9
    ....

    [result snipped]

    --
    Christopher

    raise OutofSigError
     
    Christopher Koppler, Jan 5, 2005
    #2
    1. Advertisements

  3. Daewon YOON

    Rick Holbert Guest

    It also looks like you are using an old version of Python running on an old
    version of Linux. Time to upgrade?

    Christopher Koppler wrote:

    > On Wed, 05 Jan 2005 15:36:30 +0900, Daewon YOON wrote:
    >
    >> ====
    >> Python 1.5.2 (#1, Jul 5 2001, 03:02:19) [GCC 2.96 20000731 (Red Hat
    >> Linux 7.1 2 on linux-i386
    >> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
    >> >>> x=9
    >> >>> y=4
    >> >>> x%y

    >> 1
    >> >>> for z in range(44):

    >> ... z%9
    >> File "<stdin>", line 2
    >> z%9
    >> ^
    >> SyntaxError: invalid syntax
    >>
    >> ====
    >> What's wrong with the above operation and how can I get the correct
    >> modulo result with Python?

    >
    > There's nothing wrong with the operation, but it looks like you forgot to
    > indent your loop body (which the interactive shell doesn't automagically
    > do for you):
    >
    >>>> for z in range(44):

    > ... z%9
    > ...
    >
    > [result snipped]
    >
     
    Rick Holbert, Jan 5, 2005
    #3
    1. Advertisements

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. MajorTom
    Replies:
    4
    Views:
    2,510
    MajorTom
    May 27, 2005
  2. Sunil Shukla

    floating point operation in VHDL

    Sunil Shukla, Sep 1, 2004, in forum: VHDL
    Replies:
    1
    Views:
    731
    ALuPin
    Sep 2, 2004
  3. valentin tihomirov

    operation on mux output

    valentin tihomirov, Sep 22, 2004, in forum: VHDL
    Replies:
    5
    Views:
    1,402
    valentin tihomirov
    Sep 23, 2004
  4. Aliki

    Enable/disable operation

    Aliki, Sep 27, 2004, in forum: VHDL
    Replies:
    1
    Views:
    631
    ivailokroumov
    Sep 28, 2004
  5. cltsaig

    Integer left shift operation

    cltsaig, Oct 7, 2004, in forum: VHDL
    Replies:
    4
    Views:
    11,156
    rickman
    Oct 7, 2004
  6. david ullua
    Replies:
    13
    Views:
    905
  7. raan
    Replies:
    2
    Views:
    611
  8. Buzz Lightyear
    Replies:
    10
    Views:
    1,335
    Alexander Bartolich
    Aug 12, 2009
Loading...