Assignment 2
Due date: 2/15/13 at 5pm
This assignment has two parts. Each part will require you to write a function that accomplishes a given task. Put both functions in a single file called assignment2.py, which you will submit via ramCT.
Part 1 - Software sales
Company X provides a discount for ordering in bulk quantities. Quantity discounts are given according to the following table:
| Quantity | Discount |
|---|---|
| 10-19 | 20% |
| 20-49 | 30% |
| 50-99 | 40% |
| 100 or more | 50% |
Write a function called cost(num_items, cost_per_item) that computes the cost to the customer given the number of items (num_items) and the cost per item (cost_per_item).
The function should return the total cost and the discount they got.
Part 2 - log fold change
When comparing expression of a gene in two experimental conditions a biologist will typically be interested in genes that show differences in their level of expression. This is usually quantified by the ratio of expression values (fold-change) or its logarithm (log-fold-change).
Typically a biologist will only investigate genes whose log-fold-change is above a certain threshold in absolute value.
Write a function called log_fold_change(val1, val2, threshold) whose parameters are the expression levels of a gene in two experimental conditions. The function should return two values:
the log-fold-change, where the log is base 2, and a Boolean value that indicates whether the log-fold-change is above 1 in absolute value.
Putting it all together
At the bottom of the program include code that runs the two functions. Your program should ask the user what they want to work on (sales or genomics), and according to their answer, prompts them for the input that is required for the sales/fold-change function, and then displays the result in a meaningful way (simply printing out the return value of the function is not that useful, since the user may not know what they mean). Put that code under a
# code that runs your functions
statement as shown in class. Submit your code via ramCT. At the top of each file put a comment that identifies you and the program (use a multi-line comment using triple quotes):
Submitted by Your_Name
A short description of your program"""
