CSci 1001 Problem set 3. Due Monday, Dec 2 by 11:59pm.

Problem 1 (5 points): drawing lines in a loop

Modify the lines drawing program to add another set of lines (the same number as the first one) that starts at the length that the first set ends at and then grows back to max_length.

Problem 2 (10 points): Using a loop to write song lyrics

Write a loop to print the lyrics of the song 99 Bottles of Beer. The last verse should print "Take one down and pass it around, 0 bottles of beer on the wall".

Some hints:

  1. Use a "while" loop or (better!) a "for" loop counting down
  2. Write the first line of the lyrics first, test your program. You might want to make it into a function that takes a number of bottles as a parameter.
  3. Write the second line of the lyrics. Think of how to print a number that's one less than the loop counter. If you are writing a function, add that line to a function. Test your program to make sure it still prints all of the verses correctly.
  4. Make sure the page looks nice (put each verse in a paragraph, etc.)
  5. Add a prompt or a form to ask for the starting number of bottles, then print the song counting down from that number.

Problem 3 (10 points): representation of numbers

Convert the following numbers from binary (base 2) to decimal (base 10). All numbers are positive.

  1. 10011
  2. 111
  3. 10100

Convert the following numbers from decimal to binary.

  1. 1
  2. 23
  3. 30

Convert the following numbers from hexadecimal (base 16) to decimal.

  1. A1
  2. 4B

Convert the following numbers from decimal to hexadecimal

  1. 88
  2. 139

Problem 4 (10 points): more data representation

Exercises 4 (briefly explain your answer), 18, 19, 20, 22 p. 231.

How to submit

Send all of your program files to me by e-mail. You may submit the written part (if any) in class or send it together with your problem set. Please send only ONE e-mail with your entire submission, make sure you include everything. Multiple e-mails with your homework may result in a lower grade.

CSci 1001 course web site.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.