@extends('template') @section('title') Lab 2: Nested Function Call Exercises @stop @section('content') # Lab 2: Nested Function Call Exercises **Do these exercises on the whiteboard with your partner(s).** ## Exercise Nested 1 ```py @php include DOC_ROOT . '/content/labs/lab02/starter/funs1.py'; @endphp ``` Answer the following questions for the functions `h` and `q` defined above: * **Nested 1a:**: What are the values of each of the following expressions? + `h(q('d'))` + `q(h('e'))` + `h(q(h('F')))` * **Nested 1b:** Using `h`, `q`, and `'F'`, what is a different expression than `h(q(h('F')))` that returns the same value? * **Nested 1c:** Using `h`, `q`, and `'g'`, write three different expressions that evaluate to the string `'##G???'` ## Exercise Nested 2 ```py @php include DOC_ROOT . '/content/labs/lab02/starter/funs2.py'; @endphp ``` Answer the following questions for the functions `z`, `d`, and `i` defined above: * **Nested 2a:** What are the values of each of the following expressions? + `i(d(i(z())))` + `d(i(i(z())))` * **Nested 2b:** Using only calls to `d`, `i`, and `z`, write expressions that evaluate to the following integers: + 7 + 10 + 13 + 15 + 16 * **Nested 2c:** For any nonnegative integer _n_, is it possible to express _n_ with an expression involving calls to only `d`, `i`, and `z`? Explain your answer. * **Nested 2d:** For any integer _n_ expressible involving calls to only `d`, `i`, and `z`, can there be more than one expression involving calls to only `d`, `i`, and `z` that evaluates to _n_? @include('/labs/lab02/_toc') @stop