Mean, median, mode and other statistical functions
![](/images/d/d1/Square.png)
This is a problem set. Some of these are easy, others are far more difficult. The purpose of these problems sets are to HELP YOU THINK THROUGH problems. The solution is at the bottom of this page, but please don't look at it until you have tried (and failed) at least three or four times.
The Problem[edit]
You and your date are trying to get a table at a restaurant. The parameter "you" is the stylishness of your clothes, in the range 0..10, and "date" is the stylishness of your date's clothes. The result getting the table is encoded as an int value with 0=no, 1=maybe, 2=yes. If either of you is very stylish, 8 or more, then the result is 2 (yes). With the exception that if either of you has style of 2 or less, then the result is 0 (no). Otherwise the result is 1 (maybe)[2].
date_fashion(5, 10) → 2
date_fashion(5, 2) → 0
date_fashion(5, 5) → 1
Some Code to Get You Started[edit]
# this is abstracting and conditional practice
def date_fashion(you, date):
return outcome
Take This Further[edit]
This simple program is an example of an abstraction. We take a real-world problem (getting a table at a popular restaurant) and abstract into something we can computationally solve. I'm not sure "how you are dressed" should be the only criteria that would determine if you got a table. For extra marks, please include other criteria that would determine if you could find a table.
How you will be assessed[edit]
Every problem set is a formative assignment. Please click here to see how you will be graded
References[edit]
One Possible Solution[edit]
Click the expand link to see one possible solution, but NOT before you have tried and failed!
Not yet :-)