After the lab, you should be proficient at
graphics.py
in /home/courses/cs111/handouts/lab5/
into
your lab5
directory.We'll practice writing several Python programs, each in their own text file. Name the files lab5.1.py through lab5.5.py.
Your programs will be graded on correctness, style, efficiency, and how well you tested them. Make sure you adhere to the good development and testing practices we discussed in class. Your code should be readable and your output should be useful and well-formatted.
After you've developed a correct solution to each program, restart IDLE or close and reopen the IDLE "shell" by running the program again (using F5), demonstrate that the program works using several good test cases, and save the output to a file named lab5.x.out, where x is the problem number.
clone
method to make a copy of the original
shape. Then draw the cloned shape in the window and move it to
the desired location.setCoords
method of
the GraphWin
object to adjust the coordinates of
the window. (See the reference above for more information
about setCoords
.)Screen Capture:
xv
, using the command xv
&
.You've saved the image!
Some previously created images to inspire you:
If you want to animate a group of objects, moving together, you can
use the GraphObjectGroup
class. There is an example of using the
GraphObjectGroup
class in the example.py
file in the
/home/courses/cs111/handouts/lab5
directory.
Enter the first word: zebra Enter the second word: monkey Enter the third word: pig The alphabetically first word is monkey
Enter the first word: dog Enter the second word: black cat Enter the third word: 13 The alphabetically first word is 13
Enter the first word: black Enter the second word: black cat Enter the third word: blacky The alphabetically first word is black
Since strings are immutable and given our current knowledge, you'll have to create a new string that contains all the characters except spaces from the original string. For full credit, only go through the string removing spaces if the string contains at least one space. Do not use a method to solve this problem.
Example output:
What is your string? The Beatles Your string without spaces is TheBeatles
What is your string? Help! Your string without spaces is Help!
Enter the text: we love CS w we we we l we lo we lov we love we love we love C we love CS we love C we love we love we lov we lo we l we we w
It's time to revisit our web pages. (You knew we'd get back to this sooner or later!)
public_html
directory.index.html
file into a file
called lab5.html
(in the public_html
directory).public_html
directory.lab5.html
in jEdit.Simulate a game of Rainbow Dice, a Sprenkle family tradition. Note that Rainbow Dice is much simpler to implement than the Craps game. Demonstrate your program with a goal of 3, so that you don't print out too much output.
You only get one extra credit for this--either for lab4 or lab5, not both. :)
turnin
directory.
(Review the UNIX handout if you don't
remember how to do that.)
labs/lab5
directory; otherwise, the print out will
be long and screwed up. You can move those files back into
your lab5
directory after you've printed. In other
words, you should only have the .py files you wrote and the .out files
you created in your directory when you print.
printLab.sh
command. You should probably print from the
labs
directory.
Before you print, view the file to make sure it's not too long
or has weird characters in it from the .pyc
file. One
command to view the file is gv lab5.ps
Print the file using the lpr
command introduced in the
first lab.
Labs are due at the beginning of Friday's class. You should hand
in the printed copy at the beginning of class, and the electronic
version should be in the turnin
directory before 1:20
p.m. on Friday.
Ask well before the deadline if you need help turning in your assignment!