Starting from:

$30

CSCI160 Computer Science I  Program 5b -Solved

will have you create an image that will show your initials in the display. As a 
demonstration, I’ve including my initials, with a variation on how I could draw the M. In order to 
ensure practice using loops, the only graphics command that can be used to draw in the display 
is point. You CANNOT use the line command, or any other command other than point. This 
will require a loop in conjunction with the point command to draw each line in each letter. 
Specifics 
Write your initials, or any other combination of 3 unique letters, to the display. Before starting 
each letter, write a comment stating the letter to be displayed and then give the variables 
startX and startY a value. The startX and startY variables will be the upper left hand 
corner of the letter. These variables do not have to be called startX and startY, the point is to 
have variables which store the starting location of that letter. 
Use relative locations, using the startX and startY variables, to create your letter using the 
point command. ALL commands used to draw the letter MUST use startX and/or startY or 
distances from startX or startY, such as startX + 100 or startY + 60. 
To simplify the drawing of the letters, set the width of the line from the default of 1 to something 
larger using setLineWidth(). I set the width in my example to 15.You can draw block letters, 
as I did with the leftmost M, or figure out how to include the slope to draw angled lines. Either 
approach is valid, you will not be graded on artistic style. However, each letter must include at 
least 2 lines/for loops. I decided to make each letter 100 pixels by 100 pixels. You do not have to use these 
dimensions. I think it will be easier if all of your letters have the same width and the same 
height. I would also draw the letters by hand on a graph, noting the starting and ending points of 
each line, and how they relate to the starting x and y. 
Challenge 
If you look at the letter “O” you will find 4 lines. In the simplest solution you will have 4 for loops. 
However, the letter can be created with less than 4 loops, since several of the loops will have 
some of their coordinates in common. Nothing says that two lines (parallel lines) can’t be draw 
with a single loop. I was also able to use a single loop to draw the diagonal lines in the second 
M. 
Starter code 
from SimpleGraphics import * 
setSize (700, 300) 
setBackground ("light gray") 
setOutline ("dark blue") 
setLineWidth (15) 
setWindowTitle ("Drawing TOM") 
#drawing T 
startX = 100 
startY = 100 
#I’ll give you the top line of the T 
for x in range (startX, startX + 100): 
 point (x, startY) 
... 
#drawing O 
setOutline ("white") 
startX = 220 
startY = 100 
#now draw the lines for the O 
... 
#drawing M – approach 1 
setOutline ("dark red") 
startX = 340 
startY = 100 
#now draw the lines for the first M 
... 
#drawing M – approach 2 
startX = 460 
startY = 100 
#now draw the lines for the second M 
...

More products