Create a file named pi.py that inputs the number of terms to use to approximate π as described in exercise 15 of chapter 3 on p. 78. Output both the approximation of π and the absolute value of the difference between the approximation and the value of math.pi. Here is a sample run:
enter number of terms to use to approximate pi: 100000 the approximation is: 3.1415826535897198 the difference is: 1.0000000073340232e-05
Create a file named face.py that will draw a face based on a user’s single mouse click. Make your window have size 400 by 400. Draw the face as a circle centered at the mouse click with radius 100. Draw the eyes with radius 10. The left eye should be 25 pixels to the left and 15 pixels above the center of the circle. The right eye should be 25 pixels to the right and 15 pixels above the center of the circle. Draw the mouth as an oval that is 50 pixels wide and 30 pixels high. The center of the mouth must be 40 pixels below the center of the face circle. Wait for a second mouse click and then close the window. You may color the face and eyes any color you wish and add additional shapes such as a nose or hat, but make certain the eyes and face outlines are clearly visible and in the correct location and do not require additional mouse clicks. You will need the graphics.py file that is on iLearn. Put it in the same directory as your face.py file.
After you have commented and tested your code, submit your programs by emailing the pi.py, face.py, and help.txt files to [email protected] as attachments with the appropriate subject line. You must use Capital’s webmail as some email systems send attachments differently and I automatically extract the attachment based on the email address. Use the subject CS160-1ATT for the 1PM section and CS160-2ATT for the 2PM section.
The lab will be graded using the rubric in the Course Documents section of iLearn.