Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Compose a function called that accepts a single numerical argument: a sales amount. This argument should be a positive number. If the argument is

image text in transcribed
image text in transcribed
1. Compose a function called that accepts a single numerical argument: a sales amount. This argument should be a positive number. If the argument is not valid, the output of the function is undefined. This function should return the bonus awarded based on the sales amount using the following logic: If the sales amount is greater than $10,000, then the bonus about is 5% of the sales amount. Otherwise, the bonus amount is only 2% of the sales amount. For example, \[ \begin{array}{ll} \text { calc_bonus }(15000) & \# \text { output: } 750 \\ \text { calc_bonus }(7000) & \text { \#output: } 140 \\ \text { calc_bonus }(-10) & \text { \#output: undefined } \end{array} \] 2. Compose a function called that accepts a single numerical argument: a temperature. This argument should be a floating point number. This function should return a string based upon the input temperature, determined using the following logic: if the temperature is less than 40 , return COLD, if it is between 40 and 60 (inclusive), return CHILLY, and if it is greater than 60 , return NICE. For example, \[ \begin{array}{ll} \text { tenp_feel(a) } & \# \text { output: COLD } \\ \text { tenp_feel(100) } & \text { \# output: NICE } \\ \text { tenp_feel }(60) & \text { i output; CHILLY } \end{array} \] 3. Compose a function called floor_division that accepts two numerical arguments. It should return an integer, calculated by dividing the first argument by the second. If the division is not defined, the output of the function is undefined, but the function must not throw an error. For example. \[ \begin{array}{l} \text { floor_division }(5,2) \text { i output: } 2 \\ \text { floor_division(100, 20) output: } 5 \\ \end{array} \] You are NOT allowed to use the following constructs unless specified in the assignment directions. Using the following constructs will result in 0 (zero) for the entire submission (assignment, timed test, etc.). The restricted items are as follows: - Concepts not discussed in lectures yet - String functions - Member functions - Exceptions (can use) : len () and x=x+[y1,y2,y3] - Built-in functions \& types - Exceptions (can use): str(), readline(), open(), close(), write(), read(), range(), split() - Cannot use .append, sort, etc. - Cannot use "Slicing" - Cannot use "list comprehension" - Cannot use "not in" (together) - Cannot use "in" - not allowed with conditionals - Exception (can use): with range () - Cannot use " and \{\} - Exception (can use): mathematical operations (multiply \& exponents) - Data type functions - Exceptions (can use): int(), str (), float () - Break - Continue - Nested Constructs - Exceptions (can use): 2-D list - Multiple returns \& Multiple assignments - Recursion (not allowed unless the question explicitly states otherwise) - Functions within functions (Definitions) -- invocation is fine - Default Parameters - Global variables - Keyword as variable names

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Icdt 88 2nd International Conference On Database Theory Bruges Belgium August 31 September 2 1988 Proceedings Lncs 326

Authors: Marc Gyssens ,Jan Paredaens ,Dirk Van Gucht

1st Edition

3540501711, 978-3540501718

More Books

Students also viewed these Databases questions