def createList(): # Create an empty list chars = [] # Create lowercase letters randomly and add them to the list for i in range(100): chars.append(RandomCharacter.getRandomLowerCaseLetter()) # Return the list return chars
def createList(): # Create an empty list chars = [] # Create lowercase letters randomly and add them the list for i in range(100): chars.append(RandomCharacter.getRandomLowerCaseLetter()) # Return the list return chars
def createList(): # 빈 리스트를 생성한다. chars = [] # 소문자를 랜덤하게 생성하고 리스트에 추가한다. for i in range(100): chars.append(RandomCharacter.getRandomLowerCaseLetter()) # 리스트를 반환한다. return chars
def main(): # Create a list of characters chars = [RandomCharacter.getRandomLowerCaseLetter() for x in range(100)] # Display the list print("The lowercase letters are:") displayList(chars) # Count the occurences of each letter counts = countLetters(chars) # Display counts print() print("The occurences of each letter are:") displayCounts(counts)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jan 24 11:15:32 2019 @author: yang """ # List 6-12 import RandomCharacter NUMBER_OF_CHARS = 175 # Number of characters to generate CHARS_PER_LNIE = 25 # Number of characters to display per line # Print random characters between 'a' and 'z', 25 chars per line for i in range(NUMBER_OF_CHARS): print(RandomCharacter.getRandomLowerCaseLetter(), end=" ") if (i + 1) % CHARS_PER_LNIE == 0: print() # Jump to the new line
import RandomCharacter NUMBER_OF_CHARS = 175 # Number of characters to generate CHARS_PER_LINE = 25 # Number of characters to display per line # Print random characters between 'a' and 'z', 25 chars per line for i in range(NUMBER_OF_CHARS): print(RandomCharacter.getRandomLowerCaseLetter(), end = "") if (i + 1) % CHARS_PER_LINE == 0: print() # Jump to the new line
import RandomCharacter NUMBER_OF_CHARS = 175 CHARS_PRE_LINE = 25 for i in range(NUMBER_OF_CHARS): print(RandomCharacter.getRandomDigitCharacter(), end=' |') if (i + 1) % CHARS_PRE_LINE == 0: print()
def createLists(): chars = [] for i in range(100): chars.append(RandomCharacter.getRandomLowerCaseLetter()) return chars
import RandomCharacter N = 10000 count = 0 for i in range(N): ch = RandomCharacter.getRandomUpperCaseLetter() if ch == 'A': count += 1 print("The occurrence of A is", count)
import RandomCharacter N = 100 count = 1 for i in range(N): if count % 10 == 0: print(RandomCharacter.getRandomUpperCaseLetter()) else: print(RandomCharacter.getRandomUpperCaseLetter(), end = " ") count += 1 for i in range(N): if count % 10 == 0: print(RandomCharacter.getRandomDigitCharacter()) else: print(RandomCharacter.getRandomDigitCharacter(), end = " ") count += 1
import turtle import RandomCharacter # Write text at the specified location def writeLine(text, x, y): turtle.penup() # Pull the pen up turtle.goto(x, y) turtle.pendown() # Pull the pen down turtle.write(line, font = ("Times", 18, "bold")) x = -130 y = 50 line = "" for i in range(1, 101): line += RandomCharacter.getRandomLowerCaseLetter() + " " if i % 15 == 0: writeLine(line, x, y) line = "" y -= 25 turtle.done()
#!/usr/bin/python3 # 《Python语言程序设计》程序清单6-12 # Programed List 6-12 # 测试随机生成特定类型字符的函数。 import RandomCharacter NUMBER_OF_CHARS = 175 CHARS_PER_LINE = 25 # Print random character between 'a' and 'z', 25 chars per line for i in range(NUMBER_OF_CHARS): print(RandomCharacter.getRandomLowercaseCharacter(), end=" ") if (i + 1) % CHARS_PER_LINE == 0: print()