# QUESTIONS # 1. Why are the parameters x and y used in the function definitions rather than first_num/second_num? # 2. What is meant by local and global scope of variables? # 3. What is the purpose...


# QUESTIONS<br># 1. Why are the parameters x and y used in the function definitions rather than first_num/second_num?<br># 2. What is meant by local and global scope of variables?<br># 3. What is the purpose of the return statement?<br># TASKS<br># 1. Write a new function to multiply two numbers together and return the result<br># 2. Write a new function to divide two numbers and return the result. Run the program and try entering '0' as the second number, what happens? How could you fix this?<br># 3. Write a new function to display a menu which should allow the user to change the numbers or choose which operation they would like to perform, e.g. choose from addition, multiplication, etc<br># 4. Modify your menu function to include an option to exit the program and add a loop to allow the user to restart the program until they choose the exit option<br># 5. Write a new function which takes two arguments, a number and a power and returns the number^power. You should research and use the math.pow() function to do this. What is the difference between math.pow() and **?<br># 6. Write a new function which takes two arguments, a number and the nth root (e.g. 2 would be square root, 3 cubic root<br>etc) and returns the nth root of the number. You should research an appropriate way to do this.<br># 7. Modify your menu function to include the two new functions from tasks 5 and 6<br># 8. Add comments to the code to explain what it is doing<br>白#<br>Subroutines<br>Edef my_add(x,y):<br>return x + y<br>def my subtract(x,y):<br>return x - y<br>%23<br>Main program<br>A# get initial numbers x and y<br>first_num = int(input(

Extracted text: # QUESTIONS # 1. Why are the parameters x and y used in the function definitions rather than first_num/second_num? # 2. What is meant by local and global scope of variables? # 3. What is the purpose of the return statement? # TASKS # 1. Write a new function to multiply two numbers together and return the result # 2. Write a new function to divide two numbers and return the result. Run the program and try entering '0' as the second number, what happens? How could you fix this? # 3. Write a new function to display a menu which should allow the user to change the numbers or choose which operation they would like to perform, e.g. choose from addition, multiplication, etc # 4. Modify your menu function to include an option to exit the program and add a loop to allow the user to restart the program until they choose the exit option # 5. Write a new function which takes two arguments, a number and a power and returns the number^power. You should research and use the math.pow() function to do this. What is the difference between math.pow() and **? # 6. Write a new function which takes two arguments, a number and the nth root (e.g. 2 would be square root, 3 cubic root etc) and returns the nth root of the number. You should research an appropriate way to do this. # 7. Modify your menu function to include the two new functions from tasks 5 and 6 # 8. Add comments to the code to explain what it is doing 白# Subroutines Edef my_add(x,y): return x + y def my subtract(x,y): return x - y %23 Main program A# get initial numbers x and y first_num = int(input("x= ")) second_num = int(input("y= ")) # print result of addition print("x + y =", my_add(first_num second_num)) # print result of subtraction print("x - y =", my_subtract(first_num, second_num))
Jun 03, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here