Main.Assignment2 History
Hide minor edits - Show changes to markup
# code that
# code that runs your functions
Submit the programs by email to your instructor. At the top of each file put a comment that identifies you and the program (use a multi-line comment using triple quotes):
Assignment 2Submitted by Your_NameA short description of your program
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 (:source lang=python:) if __name__ == _main_ :
# code that
(:sourceend:) 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):
(:source lang=python:) """Assignment 2 Submitted by Your_Name A short description of your program""" (:sourceend:)
Due date: 2/8/10
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.
A software company sells a package that retails for $99.
Company X provides a discount for ordering in bulk quantities.
Write a program called sales.py that asks the user to enter the number of packages purchased.
The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount.
Instructions: Decompose the task into two sub-tasks - one that computes the discount, and one that computes the total amount.
Part 2 - BMI calculator
The body mass index (BMI) is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person's BMI is calculated with the following formula:
BMI = weight x 703 / (height * height)
where weight is measured in pounds and height is measured in inches. If a person's BMI is below 18.5, the person is considered underweight; a value between 18.5 and 25 is considered normal; a value above 25 is considered overweight. More information on BMI is found on the CDC website: http://www.cdc.gov/healthyweight/assessing/bmi/adult_bmi/.
Write a program called bmi.py that asks a person for their height and weight. It then prints their BMI and tells them if they are underweight, normal, or overweight. Use functions in order to decompose the task into subtasks - computing the BMI, and printing out the appropriate message given the value of the BMI.
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
A short description of your program
A short description of your program
Submit the programs by email to your instructor. At the top of each file put a comment that identifies you and the program (use a multi-line comment using triple quotes):
Assignment 2Submitted by Your_NameA short description of your program
Assignment 2
Due date: 2/8/10
You can find many
Part 1 - Software sales
A software company sells a package that retails for $99. 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 program called sales.py that asks the user to enter the number of packages purchased.
The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount.
Instructions: Decompose the task into two sub-tasks - one that computes the discount, and one that computes the total amount.
Part 2 - BMI calculator
The body mass index (BMI) is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person's BMI is calculated with the following formula:
BMI = weight x 703 / (height * height)
where weight is measured in pounds and height is measured in inches. If a person's BMI is below 18.5, the person is considered underweight; a value between 18.5 and 25 is considered normal; a value above 25 is considered overweight. More information on BMI is found on the CDC website: http://www.cdc.gov/healthyweight/assessing/bmi/adult_bmi/.
Write a program called bmi.py that asks a person for their height and weight. It then prints their BMI and tells them if they are underweight, normal, or overweight. Use functions in order to decompose the task into subtasks - computing the BMI, and printing out the appropriate message given the value of the BMI.
You can find many
