CSC 110: Introduction to Computer Programming – HW 3 Solved

$ 29.99
Category:

Description

Possible Points: 25 points
General:
This homework has the following goals:
• Give you practice with graphical programming and with using the graphical library
• Introduce you to concepts of object-oriented programming
• To give you practice creating objects with values determined from user input
• Introduce the concept of sequences, as used in Python
• Give you practice manipulating strings and help you understand how strings are represented in the computer – one of the great things about Python is that it has many methods that facilitate string manipulation
Assignment:

1. (10 points) Problem 1 gives you practice creating and manipulating graphical objects.

a. (7 points) Write a program target1.py as described in Programming Exercise 2 on page 126 of the textbook (2nd edition page 118).

2. An archery target consists of a central circle of yellow surrounded by concentric rings of red, blue, black and white. Each ring has the same width, which is the same as the
radius of the yellow circle. Write a program that draws such a target.
Hint : Objects drawn later will appear on top of objects drawn earlier.

Hint: You will ask the user for the diameter of the archery target. How is this related to the radius of the inner circle? The larger circles’ radii can be expressed as multiples of this value.
Submit your responses to Problem 1 as two separate modules (target1.py and target2.py).
2. (15 points) Problem 2 gives you practice with interactive graphics that use mouse clicks rather than the console to get user input. It also gives your practice using coordinate transformation to make placing text in the window easier.

a. (10 points) Write a program line1.py as described in Programming Exercise 8 on page 127 of the textbook (2nd edition page 119).
This program allows the user to draw a line segment and then displays some graphical and textual information about the line segment.
Input: Two mouse clicks for the end points of the line segment.
Output:
Draw the midpoint of the segment in cyan.
Draw the line.
Print the length and the slope of the line. Formulas: dx = x2 – x1 dy = Y2 – Y1 slope = dy / dx length = sqrt(dx2 + dy2)
b. (5 points) Modify your program from part (a) so you have a second program named line2.py. This program will have the midpoint labeled, offset slightly from the actual location of the midpoint of the line.

Submit your responses to Problem 2 as two separate modules (line1.py and line2.py).
Details:
As you have done on the earlier homeworks, add comments to your Python programs describing what a line or a block of code is meant to accomplish, including your name, and other important details as a title header at the beginning of the module.
Turn In:
Submit all of your python programs for this assignment as .py files, a total of 4 modules.

Reviews

There are no reviews yet.

Be the first to review “CSC 110: Introduction to Computer Programming – HW 3 Solved”

Your email address will not be published. Required fields are marked *