▾ Part 3: Evaluate a Piecewise Function (10 points) Complete the function piecewise, which computes and returns the valu
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
▾ Part 3: Evaluate a Piecewise Function (10 points) Complete the function piecewise, which computes and returns the valu
statement, not a print statement! 8 # Test cases 9 print (f' {piecewise (2, 8):0.4f}') 10 print (f'{piecewise (15, 3):0.4f}') 11 print (f'{piecewise (-5, 12 print (f'{piecewise (27, 3):0.4f}') 6):0.4f}') 5678
▾ Part 3: Evaluate a Piecewise Function (10 points) Complete the function piecewise, which computes and returns the value of the following mathematical function, asuming that the values for x and y are given as arguments to the function. You may assume that y # 0 and that 3x² + -7>0. if x < 12 f(x, y) = S 12x - 4yl + 3x² + x ≥ 12 Note: Python has a built-in function for computing an absolute value. Do a little research to find out what it's called! Examples: Function Call Return Value piecewise (2, 8) 28.0000 piecewise (15, 3) 26.0256 piecewise (-5, 3) 22.0000 piecewise (27, 6) 46.7778 [ ] 1 import math 2 3 def piecewise(x, y): 4 return 0 # DELETE THIS LINE and start coding here. # Remember: end all of your functions with a return