Page 1 of 1

### ASCII character table

Posted: Thu Sep 29, 2016 12:17 am
Write a program that displays the characters in the ASCII character table from ! to ~. Display ten characters per line. The characters are separated by exactly 1 space. This has to be done using turtle.

The problem I am having with this program is getting the characters into rows of 10 I can get the characters to print in rows but it just prints the same characters in each row. I can't seem to figure this one out. Any pointers would be greatly appreciated.

Code: Select all
`     import turtley = 0                    for j in range(10):          x = -100                 for a in range(1):    print(a, end = '')    for b in range(33, 43):         turtle.penup()               turtle.goto(x, y)         turtle.pendown()         turtle.write(chr(b))         x += 10   y += 15     `

### Re: ASCII character table

Posted: Thu Sep 29, 2016 1:12 pm
Pointers? Okay. Try moving through the for-loops by yourself and keep track of how the value of each variable changes or does not change even though you might expect it to.

### Re: ASCII character table

Posted: Thu Sep 29, 2016 10:35 pm
Code: Select all
`    import turtley = 0                    for j in range(10):          x = -100                 for b in range(33, 126):         turtle.penup()               turtle.goto(x, y)         turtle.pendown()         turtle.write(chr(b))         x += 10   y += 15     `

I had the range wrong in the second FOR this is the updated one

### Re: ASCII character table

Posted: Fri Sep 30, 2016 1:25 pm
Finally got it
Code: Select all
`    import turtley = 0                    for j in range(10):          x = -100                 for b in range(33, 43):         turtle.penup()               turtle.goto(x, y)         turtle.pendown()         turtle.write(chr(b))         x += 10   y += 15   breaky = 15for c in range(1):    x = -100    for d in range(44, 54):        turtle.penup()        turtle.goto(x, y)        turtle.pendown()        turtle.write(chr(d))        x += 10    y += 15    breaky = 30for c in range(1):    x = -100    for e in range(55, 65):        turtle.penup()        turtle.goto(x, y)        turtle.pendown()        turtle.write(chr(e))        x += 10    y += 15    breaky = 45for c in range(1):    x = -100    for f in range(66, 76):        turtle.penup()        turtle.goto(x, y)        turtle.pendown()        turtle.write(chr(f))        x += 10    y += 15    breaky = 60for c in range(1):    x = -100    for g in range(77, 87):        turtle.penup()        turtle.goto(x, y)        turtle.pendown()        turtle.write(chr(g))        x += 10    y += 15    breaky = 75for c in range(1):    x = -100    for h in range(88, 98):        turtle.penup()        turtle.goto(x, y)        turtle.pendown()        turtle.write(chr(h))        x += 10    y += 15    breaky = 90for c in range(1):    x = -100    for g in range(99, 109):        turtle.penup()        turtle.goto(x, y)        turtle.pendown()        turtle.write(chr(g))        x += 10    y += 15    break y = 105for c in range(1):    x = -100    for h in range(110, 120):        turtle.penup()        turtle.goto(x, y)        turtle.pendown()        turtle.write(chr(h))        x += 10    y += 15    breaky = 120for c in range(1):    x = -100    for i in range(121, 127):        turtle.penup()        turtle.goto(x, y)        turtle.pendown()        turtle.write(chr(i))        x += 10    y += 15    break                 `