% 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. Advertising

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

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

    floating point operation in VHDL

    Sunil Shukla, Sep 1, 2004, in forum: VHDL
    Replies:
    1
    Views:
    636
    ALuPin
    Sep 2, 2004
  3. david ullua
    Replies:
    13
    Views:
    669
  4. raan
    Replies:
    2
    Views:
    452
  5. Buzz Lightyear
    Replies:
    10
    Views:
    1,124
    Alexander Bartolich
    Aug 12, 2009
Loading...

Share This Page