next up previous
Next: About this document ...

Milestone #2
CpSc 481/681: Skills for Visual Computing
School of Computing
Clemson University
Solving Problems with Python
Assignment, If and While
Brian Malloy, PhD
September 22, 2009



The purpose of this milestone is to help you to become familiar with the Python language, with programming language constructs and with the logic needed to solve problems using a programming language Your assignment is to use the python language to solve the problems listed below.

  1. Getting off the ground: ``Big Timmy'' is a 150 pound 5th grader and wants to use the see-saw on the playground. But, there is no kid that weighs enough to get him off the ground! So a group of 1st graders decided they would team up and give it a shot. Assuming each of the 1st graders weighs 30 pounds, how many would have to pile on the other end of the see-saw to move "Big Timmy"?

  2. The Building Boats Problem: A rival tribe has somewhere between 50 and 150 boats. You have none. Even though you don't need boats, your pride won't let a rival tribe have more than you. Luckily, they are only making 1 per day, while your people can make 4 a day. Input the number of boats the rival tribe has, then calculate how many days it will take for your tribe to have at least as many as them.

  3. The Factors of Three: Write a program that will find and print the first 100 factors of three.

  4. The Bartender Problem: Are you tired of looking at ID's? Do you wish there was a way to easily determine someone's age without looking at a cumbersome calendar? Well, with the invention of the Python Programming Language and the while loop, it has never been easier. All you have to do is input the year the person says they were born and magically this handy dandy computational device will perform mega ultra complicated calculatory functions and determine if the person is over 21. BUT WAIT, there's more! If you don't believe them ...the trusty dusty while loop will re-ask for the real birth date until the truth comes out. Once it determines the person is not 21 it will promptly print out their proper age and dutifully ask the person to vacate the premises. Normally this program sells for billions of dollars, but for today only, we are giving it away for free. Simply ask any student in CpSc 481/681, and they will provide this program free.

  5. The Power of Two: An Arabian chieftan called upon a neighboring chieftan to help him in a feud. The neighboring chief agreed, provided that the feuding chieftan would place pennies on a checkerboard as follows: place one penny the first day, two pennies the second day, four pennies the third day, and so forth. Doubling the pennies each day. How much money did the feuding chief have to pay the neighboring chief?

  6. Guess the Number: Write a program that will pick a random number from 1 to 100 and then ask the user to guess the number. Count the number of trials required by the user to guess the number.

  7. Primes: Write a program that will find and print the prime numbers from 1 to 200.

Your assignment must be submitted, using the handin command, by 8 AM on Wednesday, September 23rd, 2009. Please compress the directory that contains your python programs and include a readme that contains your name, the course number, and an explanation of the submissions and the filenames. The syntax of the zip and tar commands is:

        zip -r <dir>.zip <dir>
        tar -zcvf <dir>.tar.gz <dir>

And the syntax for the handin command is:

        handin.481.1 2 <compressed directory name>

Where handin.481.1 means that you are using the handin command for CpSc 481, Section 1. The means that this is the second milestone and compressed directory name is the name of the directory that you compressed using either zip or tar.

Good luck with the assignment, and I hope that this milestone helps you to become more comfortable with the Python Programming Language.




next up previous
Next: About this document ...
Brian Malloy 2009-09-22