Question: USING PYTHON! The second function you will write should be called varOrd. Your function should take two (2) arguments, an integer and a string. The
USING PYTHON!
The second function you will write should be called varOrd. Your function should take two (2) arguments, an integer and a string. The function should return one (1) integer calculated as follows. If the input integer is 1, the function should return the sum of the return value of the ord() function on each character of the string (e.g., varOrd(1, cat) should return the result of ord(c) + ord(a) + ord(t)). If the input integer is 2, the function should first sum the return value of the ord() function on each character of the string and second return that value modulus 3 (e.g., varOrd(2, cat) should return the result of (ord(c) + ord(a) + ord(t)) mod 3). If the value of the input integer is 3, the function should return the factorial of the length of the string (e.g., varOrd(3, cat) should return the result of 3!). If the value of the input integer is anything else, the function should return -1 (e.g., varOrd(6, cat) should return -1)..
Testing: Create your own test cases.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
