Difference between revisions of "CSC111 HW 1 2011"

From dftwiki3
Jump to: navigation, search
(Problem #3)
(Problem #4)
Line 82: Line 82:
 
* Create a program called '''hw1d.py''' that uses the same list as in Problem #2 and that outputs the names in this fashion:
 
* Create a program called '''hw1d.py''' that uses the same list as in Problem #2 and that outputs the names in this fashion:
  
+------------------+
+
+------------------+
|            Sleepy|
+
|            Sleepy|
|            Sneezy|
+
|            Sneezy|
|          Bashful|
+
|          Bashful|
|            Happy|
+
|            Happy|
|            Grumpy|
+
|            Grumpy|
|            Dopey|
+
|            Dopey|
|              Doc|
+
|              Doc|  
+------------------+
+
+------------------+
  
 
:Note that there are now only two lines of dashes, and all the names fit ''inside the box''.
 
:Note that there are now only two lines of dashes, and all the names fit ''inside the box''.

Revision as of 13:42, 13 September 2011

--D. Thiebaut 13:59, 13 September 2011 (EDT)




Page under construction!
UnderConstruction.jpg


Problem 1

  • Write a python program called hw1a.py that uses a list of names, defined as follows:
  dwarfNames = [ "Sleepy", "Sneezy", "Bashful", "Happy", "Grumpy", "Dopey", "Doc" ]
and prints them with boxes around them. This time the boxes are all 20 characters in length. The length of the box is fixed.
+------------------+
| Sleepy           |
+------------------+

+------------------+
| Sneezy           |
+------------------+

etc...
  • Note that there is one blank line printed between each box.
  • Create a program that uses a main function, as we did in class on Tuesday.
  • When you are done, transfer your program to your Linux 111a-xx account, and submit it as follows (more info on how to do that in class on Thursday 9/15).
 submit hw1 hw1a.py

Problem #2

  • Same problem as Problem #1, but this time the list is slightly different. Some names have a space at the end, some not. The reason is that I want all names to contain an even number of characters.
  dwarfNames = [ "Sleepy", "Sneezy", "Bashful ", "Happy ", "Grumpy", "Dopey ", "Doc " ]
  • Your assignment is to write a program called hw1b.py that displays the list of names centered in a box that has long sides 20 characters in length.
+------------------+
|      Sleepy      |
+------------------+

+------------------+
|      Sneezy      |
+------------------+

etc...


  • When you are done, transfer your program to your Linux 111a-xx account, and submit it as follows:
 submit hw1 hw1b.py


Problem #3

  • Create a program called hw1c.py that uses the same list as in Problem #2 and that outputs the names in this fashion:
+------------------+
|Sleepy            |
|Sneezy            |
|Bashful           |
|Happy             |
|Grumpy            |
|Dopey             |
|Doc               |
+------------------+ 
Note that there are now only two lines of dashes, and all the names fit inside the box.
  • Submit your program as follows:
   submit hw1 hw1c.py

Problem #4

  • Create a program called hw1d.py that uses the same list as in Problem #2 and that outputs the names in this fashion:
+------------------+
|            Sleepy|
|            Sneezy|
|           Bashful|
|             Happy|
|            Grumpy|
|             Dopey|
|               Doc| 
+------------------+
Note that there are now only two lines of dashes, and all the names fit inside the box.
  • Submit your program as follows:
   submit hw1 hw1d.py