Difference between revisions of "CSC111 Homework 1 2014"

From dftwiki3
Jump to: navigation, search
(How to Submit Homework Assignments)
(How to Submit Homework Assignments)
Line 170: Line 170:
 
<br />
 
<br />
 
=How to Submit Homework Assignments=
 
=How to Submit Homework Assignments=
 +
<onlysmith>
 
In order to submit your homework, you will need a special computer account and a 2-letter Id.  Your two-letter Id is listed on this [[CSC111 2-Letter Ids 2014| page]].  If you do not find your Smith Id (99xxxxxxx) listed on this page, it is very likely because you registered late.  In this case, please send an email to '''dthiebaut@smith.edu''' right away so that you can be added to the list.
 
In order to submit your homework, you will need a special computer account and a 2-letter Id.  Your two-letter Id is listed on this [[CSC111 2-Letter Ids 2014| page]].  If you do not find your Smith Id (99xxxxxxx) listed on this page, it is very likely because you registered late.  In this case, please send an email to '''dthiebaut@smith.edu''' right away so that you can be added to the list.
  
Line 176: Line 177:
 
<center>'''[http://cs.smith.edu/~thiebaut/111b/submit1.php http://cs.smith.edu/~thiebaut/111b/submit1.php]'''</center>
 
<center>'''[http://cs.smith.edu/~thiebaut/111b/submit1.php http://cs.smith.edu/~thiebaut/111b/submit1.php]'''</center>
  
 +
</onlysmith>
 
<br />
 
<br />
 
<br />
 
<br />

Revision as of 12:06, 2 February 2014

--D. Thiebaut (talk) 10:42, 30 January 2014 (EST)





This homework assignment is due on Thursday 02/06 evening, at midnight. Assignments submitted after this date and time will not be graded.

For this first assignment you should work individually. As soon as we have discussed the article on Pair Programming you can try this method with a partner who's also taking this class.

You should do this homework with Python 3 IDLE, either on your own laptop or on one of the computers in the Science Center. Make sure to save your program to your H: drive if you work on a computer that is not yours.

When you are done with each program you can submit it as explained at the end of this page.




Problem #1

  • Write a python program called hw1a.py (use this exact name, please!) 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.
  • This is just an extension of what we did in Lab #1. Review the lab is you do not know how to get started.


Problem #2

  • Create a program called hw1b.py that uses the same list as in Problem #1:


  dwarfNames = [ "Sleepy", "Sneezy", "Bashful", "Happy", "Grumpy", "Dopey", "Doc" ]


However, your new program should output 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.


Problem #3

  • Create a program called hw1c.py that uses the same list as in Problem #1.


  dwarfNames = [ "Sleepy", "Sneezy", "Bashful", "Happy", "Grumpy", "Dopey", "Doc" ]


This time, your new program should output 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.

Problem #4

  • Create a program called hw1d.py that uses the same list as in Problem #1.


  dwarfNames = [ "Sleepy", "Sneezy", "Bashful", "Happy", "Grumpy", "Dopey", "Doc" ]
Your assignment for this program is to output the names in this fashion:
 +-------------------------------------+
 |           Sleepy | Sleepy           |
 |           Sneezy | Sneezy           |
 |          Bashful | Bashful          |
 |            Happy | Happy            |
 |           Grumpy | Grumpy           |
 |            Dopey | Dopey            |
 |              Doc | Doc              | 
 +-------------------------------------+
  • Your program must use a loop.


Hint: Try first to make your program generate this output:

 Sleepy Sleepy  
 Sneezy Sneezy           
 Bashful Bashful          
 Happy Happy            
 Grumpy Grumpy           
 Dopey Dopey            
 Doc Doc

Then, when you have this working, modify your program to get this:

 Sleepy | Sleepy  
 Sneezy | Sneezy           
 Bashful | Bashful          
 Happy | Happy            
 Grumpy | Grumpy           
 Dopey | Dopey            
 Doc | Doc

Then add the | symbols at both ends of each line. Then add the extra spaces. Then the top and bottom lines of dashes...


Optional

  • This problem is only for people who have done some programming before and feel they need some more challenge than provided by the other problems. TAs are not allowed to help with this extra-credit problem. If this problem seems too challenging, don't attempt to work on it; I am making it available only to people with previous programming experience.
  • Write a program called hw1x.py that uses the list of names defined as follows:
dwarfNames = [ "Sleepy", "Sneezy", "Bashful", "Happy", "Grumpy", "Dopey", "Doc" ]
  • and that outputs the names all on one line, in a box, as follows:
 +---------------------------------------------+
 |Sleepy Sneezy Bashful Happy Grumpy Dopey Doc | 
 +---------------------------------------------+



Hint: Play with these statements in the console window:
  word1 = "hello"
  word2 = "world!"
  sentence = word1 + " " + word2
  print( sentence )

This should give you some ideas...




How to Submit Homework Assignments


This section is only visible to computers located at Smith College