Results 1 to 4 of 4

Math Help - Python - Repetition (Iteration)

  1. #1
    Newbie
    Joined
    Dec 2007
    From
    UK
    Posts
    23

    Question Python - Repetition (Iteration)

    Convert the following while loop into for loops and the for loops into while loops.

    *
    Attached Files Attached Files
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member
    earboth's Avatar
    Joined
    Jan 2006
    From
    Germany
    Posts
    5,830
    Thanks
    123
    Quote Originally Posted by *skywalker* View Post
    Convert the following while loop into for loops and the for loops into while loops.

    *
    Hello,

    replace your text from
    >>> iteration = 0

    by:
    Code:
    for iteration in range(99):
    	if not char == “\t”:
    		print “Keep going?”
    		char = raw_input()
    (Personal remark: It is a very long time ago since I've written programs in Python so please check my answers)
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Dec 2007
    From
    UK
    Posts
    23
    Quote Originally Posted by earboth View Post
    Hello,

    replace your text from
    >>> iteration = 0

    by:
    Code:
    for iteration in range(99):
        if not char == “\t”:
            print “Keep going?”
            char = raw_input()
    (Personal remark: It is a very long time ago since I've written programs in Python so please check my answers)
    iv checked this in python and a SyntaxError:invalid syntax appears and highlights the code shown below!??!


    >>> char = ""
    >>> print " Press Tab Enter to stop and Enter to keep going ... "
    Press Tab Enter to stop and Enter to keep going ...
    >>> for iteration in range(99):
    if not char == \t”:
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Super Member
    earboth's Avatar
    Joined
    Jan 2006
    From
    Germany
    Posts
    5,830
    Thanks
    123
    Quote Originally Posted by *skywalker* View Post
    iv checked this in python and a SyntaxError:invalid syntax appears and highlights the code shown below!??!


    >>> char = ""
    >>> print " Press Tab Enter to stop and Enter to keep going ... "
    Press Tab Enter to stop and Enter to keep going ...
    >>> for iteration in range(99):
    if not char == \t”:
    Hello,

    I've written the text into your word doc and obviously word uses different characters to start and to end a text.

    Copy the next line into the program and I hope evrything will be OK:

    if not char == "\t":
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Combination with repetition
    Posted in the Statistics Forum
    Replies: 5
    Last Post: October 17th 2011, 04:18 PM
  2. Python nth prime
    Posted in the Math Software Forum
    Replies: 1
    Last Post: August 16th 2011, 11:06 PM
  3. Permutations without Repetition
    Posted in the Discrete Math Forum
    Replies: 3
    Last Post: October 29th 2009, 06:29 AM
  4. repetition
    Posted in the Math Topics Forum
    Replies: 2
    Last Post: June 30th 2008, 04:13 PM
  5. Python-conditions!!!
    Posted in the Math Software Forum
    Replies: 1
    Last Post: December 8th 2007, 05:27 AM

Search Tags


/mathhelpforum @mathhelpforum