Write a recursive function named get_max_ascii(word) which takes a string as a parameter and returns the maximum ASCII c
Posted: Sat May 14, 2022 3:39 pm
IN PYTHON
Write a recursive function named get_max_ascii(word) which takes a string as a parameter and returns the maximum ASCII code of the letters in the parameter string. For example, the following code: print(get_max_ascii('abc')) #a = 97, b = 98, c = 99 = produces 99 Note: this function has to be recursive; you are not allowed to use loops to solve this problem. You can assume that the parameter string is not empty. You may find the ord() function is helpful. For example: Test Result print(get_max_ascii('This is a Test')) 116 print(get_max_ascii('T')) 84
Consider some mathematical function f defined such that f(1)=3 if(n)= f(n-1)+2) Write a python function evaluate_f(number) which takes an integer as a parameter and computes the tuple (f(n), k) where k is the number of recursive function calls required to compute f(n). Note that the number of recursive function calls does not include the initial function call, e.g. for f(0) the number of recursive function calls is zero (base case, so result is returned without recursive call) and for f(1) the number of recursive function calls is one (recursive call of f(-1)). You can assume that all input to the function will be an integer >= 1. This function has to be recursive; you are not allowed to use loops to solve this problem! For example: Test Result val = evaluate_f(3) (7, 2) print(val) (5, 1) val = evaluate_f(2) print(val) val = evaluate_f(4) (9, 3) print(val) val = evaluate_f(8) (17, 7) print(val)
Write a recursive function named get_max_ascii(word) which takes a string as a parameter and returns the maximum ASCII code of the letters in the parameter string. For example, the following code: print(get_max_ascii('abc')) #a = 97, b = 98, c = 99 = produces 99 Note: this function has to be recursive; you are not allowed to use loops to solve this problem. You can assume that the parameter string is not empty. You may find the ord() function is helpful. For example: Test Result print(get_max_ascii('This is a Test')) 116 print(get_max_ascii('T')) 84
Consider some mathematical function f defined such that f(1)=3 if(n)= f(n-1)+2) Write a python function evaluate_f(number) which takes an integer as a parameter and computes the tuple (f(n), k) where k is the number of recursive function calls required to compute f(n). Note that the number of recursive function calls does not include the initial function call, e.g. for f(0) the number of recursive function calls is zero (base case, so result is returned without recursive call) and for f(1) the number of recursive function calls is one (recursive call of f(-1)). You can assume that all input to the function will be an integer >= 1. This function has to be recursive; you are not allowed to use loops to solve this problem! For example: Test Result val = evaluate_f(3) (7, 2) print(val) (5, 1) val = evaluate_f(2) print(val) val = evaluate_f(4) (9, 3) print(val) val = evaluate_f(8) (17, 7) print(val)