Question: Part 1Exercises - Functions Enter T for True or F for False. _____ (1) This function definition is valid. def my_Func1(userNumber) : _____ (2) This
Part 1Exercises - Functions
Enter T for True or F for False.
_____ (1) This function definition is valid. def my_Func1(userNumber) :
_____ (2) This function definition is valid. def my_Func2(userNumber + 2) :
_____ (3) This function definition has 2 parameters. def amount(x, y, z) :
_____ (4) This function definition has a single parameter. def volSphere(radius) :
_____ (5) This function definition is parameter - less. def GrossPay() :
Part 2 Programming Exercises - Functions
# function definition
def computeTheSquare(numberToSquare) :
return numberToSquare * numberToSquare
# a variable is assigned a value
givenNumber = 13
# the function is called
theResult = computeTheSquare(13)
# the result of the function call
print(givenNumber, "squared is", theResult)
For the following exercises, refer to the above function definition and the above function call given above.
(1) ( Functions )
Predict the result when the above code statements are executed.
(a) 196 (b) 1313 (c) 26 (d) 13 (e) 169
(2) ( Functions )
How many parameters does the function named computeTheSquare have?
(a) 0 (b) 1 (c) 2 (d) 3 (e) 4
For the following exercises, use this scenario and the given function definition:
In geometry, a pyramid is a form of a polyhedron. The volume of a right pyramid, whose base is a rectangle, is given as
V = ( 1 / 3 ) ( l w h )
where V is the volume of the pyramid
l is the base length
w is the base width
h is the pyramid height
A function that returns the volume of a right pyramid is shown below.
def volumeOfPyramid(baseLength, baseWidth, pyramidHeight) :
return baseLength * baseWidth * pyramidHeight * (1.0 / 3.0)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
