You need to plan your drawing carefully
and map out co-ordinates. The drawing is simply a question of the
placement of rectangles, lines, ovals, etc. By the way, one thing
that is not totally simple in the drawing above is the filled-in
triangle for the roof. You'll note that JES does not contain a
function called addTriangleFilled, so you have to make this by drawing
a large number of lines, using a for statement. (If you can't
figure out how to do this, just draw the outline of the roof.)
2. (a) Write a python function that simulates the roll of two
dice. The function rollDice() should
return a value between 2 and 12 inclusive. You do this by
simulating each the roll of each die separately, giving an answer that
is an integer chosen from {1,2,3,4,5,6}, each with equal probability,
and then returning the sum of the two rolls. (HINT: We'll
discuss how to do this in class, but the idea is to tweak random() so
that it returns a floating point number uniformly distributed in the
range 0 to 6 (excluding 6), and then use the int function).
(b) Write a function countDice(numrolls,outcome) that calls your
function from Problem 1 to simulate numrolls rolls of two dice and
return how many times outcome is obtained as a result. For
instance, if you type countDice(10000,7)
in the Command Window, you should find how many times 7 came up in
10000 rolls of the dice. (If you repeatedly do this, you will get
a different answer each time, because of the randomness in the
simulation, but the answer should be approximately 1667.)
Submit a zipped folder that contains two .py files, with your
solutions to Problems 1 and 2, and bring a printout to class. As
usual, your name should appear as a comment in each program. Note
that the answers to 2(a) and (b) should be in a single file.