Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 6 - Functions - Programming Exercises - Page 211: 6.36

Answer

code

Work Step by Step

# 6.36 (Generate random characters) Use the functions in RandomCharacter in # Listing 6.11 to print 100 uppercase letters and then 100 single digits, printing ten # per line. # Generate a random digit character from random import randint def getRandomCharacter(ch1, ch2): return chr(randint(ord(ch1), ord(ch2))) def getRandomDigitCharacter(): return getRandomCharacter('0', '9') # Generate a random uppercase letter def getRandomUpperCaseLetter(): return getRandomCharacter('A', 'Z') def main(): for i in range(100): c = getRandomUpperCaseLetter() print(c, end=' ') if (i + 1) % 10 == 0: print() print() for i in range(100): c = getRandomDigitCharacter() print(c, end=' ') if (i + 1) % 10 == 0: print() main()
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.