一、正常输出方法设计的代码结构
老规矩用正常输出法设计代码结构
def getRandomCharacter(ch1, ch2):
return chr(random.randint(ord(ch1), ord(ch2)))
def getRandomLowerCaseLetter():
return getRandomCharacter('a', 'z')
count = 0
for i in range(100):
count += 1
a = getRandomLowerCaseLetter()
print(a, end=" ")
if count % 15 == 0:
print()
二、使用turtle
def getRandomCharacter(ch1, ch2):
return chr(random.randint(ord(ch1), ord(ch2)))
def getRandomLowerCaseLetter():
return getRandomCharacter('a', 'z')
turtle.penup()
xCoo = 0
yCoo = 50
turtle.goto(xCoo, yCoo)
count = 0
for i in range(15):
count += 1
a = getRandomLowerCaseLetter()
turtle.goto(xCoo + (9 * i), yCoo)
turtle.write(a)
for j in range(1,10):
a = getRandomLowerCaseLetter()
turtle.goto(xCoo + (9 * i), yCoo + (9 * j))
turtle.write(a)
turtle.done()
最近设计的都是从下往上打印。
三、我之前做了结果没看见
def getRandomCharacter(ch1, ch2):
return chr(random.randint(ord(ch1), ord(ch2)))
def getRandomLowerCaseLetter():
return getRandomCharacter('a', 'z')
turtle.penup()
for i in range(15):
turtle.goto(28 * i, 28)
a = getRandomLowerCaseLetter()
turtle.write(a, font=("", 10, ""))
for j in range(0, 10):
turtle.goto(28 * i, -28 * j)
a = getRandomLowerCaseLetter()
turtle.write(a, font=("", 10, ""))
turtle.hideturtle()
turtle.done()