Difference between revisions of "CSC111 Lab 11 2015"

From dftwiki3
Jump to: navigation, search
Line 10: Line 10:
 
==Demonstration Example==
 
==Demonstration Example==
 
<br />
 
<br />
* Create a new new program called Lab11_0.py and copy the code from this [[CSC111 List of Tuples Demo| program]].
+
* Create a new new program called '''Lab11_0.py''' and copy the code from this [[CSC111 List of Tuples Demo| program]].
 
* Carefully read the program to see what it does, and how it does it.
 
* Carefully read the program to see what it does, and how it does it.
 
* Run the program to verify that it works well.
 
* Run the program to verify that it works well.
Line 20: Line 20:
 
==Problem 1: Animals==
 
==Problem 1: Animals==
 
<br />
 
<br />
The text below contains names of animals and their speed, expressed in miles per hour.  Write a Python program (no need to write classes for this problem) based on the preparation problem above, and make your program output the following quantities:
+
The text below contains names of animals and their speed, expressed in miles per hour.  Write a Python program called '''Lab11_1.py''' (no need to write classes for this problem) based on the preparation problem above, and make your program output the following quantities:
 
# The list of '''all''' the animals ranked by speed.  Fastest first.
 
# The list of '''all''' the animals ranked by speed.  Fastest first.
 
# The 10 fastest animals listed in order of decreasing speed
 
# The 10 fastest animals listed in order of decreasing speed
Line 68: Line 68:
 
=Problem 2: Presidents=
 
=Problem 2: Presidents=
 
<br />
 
<br />
Below is a CSV list (coma-separated values) of past presidents.  Using similar Python code as you have used for the previous problem, process this list and output:
+
Below is a CSV list (coma-separated values) of past presidents.  Using similar Python code as you have used for the previous problem, write a program ('''Lab11_2.py''') that will process this list and output:
 
<br />
 
<br />
 
# the list of presidents sorted alphabetically.  Your program should simply print the names, one per line.  No additional information is required.
 
# the list of presidents sorted alphabetically.  Your program should simply print the names, one per line.  No additional information is required.
Line 208: Line 208:
 
* Modify the loop in your main program so that it makes both the MyRect object and the MyCirc object (that you will have created) move together.   
 
* Modify the loop in your main program so that it makes both the MyRect object and the MyCirc object (that you will have created) move together.   
 
<br />
 
<br />
=Car with 2 rectangles: one with a label showing Taxi, one without for the top.=
+
=Building a Car with MyRect=
 
<br />
 
<br />
 
* Locate the program you wrote  a while back, that displays a car on the graphic window (with a body, two wheels and a top).
 
* Locate the program you wrote  a while back, that displays a car on the graphic window (with a body, two wheels and a top).
* Save your code in a program called '''lab11_5.py'''.
+
* Save your code in a program called '''lab11_4.py'''.
 
* In case you had implemented a text label as part of your Car class, please remove it.  Make sure your program displays only a car with 2 wheels and two rectangles, one for the body, one for the top.
 
* In case you had implemented a text label as part of your Car class, please remove it.  Make sure your program displays only a car with 2 wheels and two rectangles, one for the body, one for the top.
 
<br />
 
<br />
 
==Using MyRect to build the Car==
 
==Using MyRect to build the Car==
 
<br />
 
<br />
* Modify  
+
* Add your '''MyRect''' class to your program, at the top, before your '''Car''' class.
 +
* Modify your Car class so that it uses MyRect instead of Rectangle for its body.  Make the label inside the body "TAXI" or whatever name you feel should be on your car.  Make sure that this label is the one generated in MyRect.  Your Car class should not contain a self.label member variable any longer.
 +
* Verify that your program correctly displays the car.
 +
* Make your car move some deltax, deltay in a loop, the same way you moved the MyRect and MyCirc objects in the previous problem.  Verify that the car moves correctly, including its label.
 +
<br />
 +
=Animal Class=
 
<br />
 
<br />
=Animal Class,
 
 
  
  

Revision as of 11:39, 12 April 2015

--D. Thiebaut (talk) 19:36, 11 April 2015 (EDT)



...