Question: Write a function called compare _ numbers. It should have the following: 2 inputs which are called num _ 1 and num _ 2 in
Write a function called comparenumbers. It should have the following:
inputs which are called num and num in that order
an output called info
has a nested function called comparison. This nested function should have the following:
inputs which are called firstnum and secondnum in that order
an output called compresult
If firstnum is bigger than secondnum, set compresult to
Otherwise, set compresult to
End of comparison function instructions
One good use of a Nested function is if we have a piece of code that we want to repeat various times across a function. Lets look at an example of that:
Write a function called comparenumbers. It should have the following:
inputs which are called num and num in that order
an output called info
has a nested function called comparison. This nested function should have the following:
inputs which are called firstnum and secondnum in that order
an output called compresult
If firstnum is bigger than secondnum, set compresult to
Otherwise, set compresult to
End of comparison function instructions
Using the function called comparison, compare num and num with num being the firstnum.
Assign the result to a variable called fish
Using the function called comparison for a second time, compare num to num being the firstnum.
Assign the result to a variable called cat
calculate the sum of fish and cat. Assign this result to info
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
