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.
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 exceptionanomalous or exceptional conditions requiring special processing – often changing the normal flow of program execution that if either of you has style of 2 or less, then the result is 0 (no). Otherwise the result is 1 (maybe).
date_fashion(5, 10) → 2 date_fashion(5, 2) → 0 date_fashion(5, 5) → 1
Some Code to Get You Started
# this is abstracting and conditional practice def date_fashion(you, date): return outcome
Take This Further
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 determineObtain the only possible answer. if you got a table. For extra marks, please include other criteria that would determineObtain the only possible answer. if you could find a table.
How you will be assessed
Every problem set is a formative assignment. Please click here to see how you will be graded
One Possible Solution
Click the expand link to see one possible solution, but NOT before you have tried and failed!
1 Not yet :-)