Remember to run update21 to get the files needed for this assignment. The program handin21 will only submit files in the cs21/homework/4 directory.
Your programs are graded on both correctness and style. Please review the comments regarding programming style on the main page
Some of the problems will have optional components that allow you to
further practice your skills in python. Optional portions will not be
graded, but may be interesting for those wanting some extra challenges.
Write a function by editing the file username.py that computes a computer user name by concatenating the first letter of the user's first name, (upto) the first 6 letters of the user's lastname, and the digit '1'.
Usernames should obey the following rules:
The input parameters of this function are the first and last name of the user. The function should return the username. Test your function by writing a small main program that calls your function. Use at least three names, including at least one last name with less than six characters, and one name with punctuation.
A sample run is shown below:
username("Andrew", "Danner") = adanner1 username("Vanilla", "Ice") = vice1 username("Eddie", "Van Halen") = evanhal1 username("Brian", "St. Pierre") = bstpier1 username("Kareem", "Abdul-Jabbar") = kabdulj1
Write a function move_point that takes as input a Point object p, and two distances x and y and returns a new Point object p' that is identical to p but is moved a distance x away from p in the x-direction and a distance y away from p in the y-direction. Your function may use the getX and getY methods for points, but cannot use the move method.
Write a function move_polygon that takes a Polygon object P, and two distances x and y as input and returns a new Polygon object P' that has the same vertices as P but is moved a distance x and y in the x and y directions, respectively. Again, you cannot use the move method in the graphics class, but you can use the move_point function you just defined.
Write a small sample main() program that tests your functions. An example of a test program is shown below
dx1'=dx cos(t) - dy sin(t) dy1'=dx sin(t) + dy cos(t) where dx= x1-x2, dx1'= x1'-x2 dy= y1-y2, dy1'= y1'-y2
The python math functions sin and cos expect the angle in radians. To convert from degrees to radians, use rad=deg*pi/180.
Some example output is shown below. The test file rottest.py in your homework/4 has a copy of the code shown below.