Question

In: Computer Science

Please answer all qestions 1) Within a function header, for example: def gcd(a, b): The variables...

Please answer all qestions

1) Within a function header, for example:

def gcd(a, b):

The variables that appear within parentheses are called what?

Group of answer choices

a)variables

b)attributes

c)parameters

d)arguments

2)Question 31 pts

Within a function call, for example:

g = gcd(142, b);

The text that appears within parentheses is called what?

Group of answer choices

a) variables

b) attributes

c) parameters

d)arguments

3) Question 42 pts

Given this function header:

def compute(x, y, z):

And this code to call that function:

x = 7
result = compute(3, 2, x)

Within the function compute, what value will be stored in the parameter x ?

Group of answer choices

2

3

7

None of the above

4) Question 51 pts

What is wrong with the following function?

def area circle(radius):
    """Compute and return the area of a circle."""
    area = math.pi * radius ** 2
    return area

Group of answer choices

The function name includes a space character.

The function has no parameters.

The function redefines its parameter.

The function doesn't return a value.

5) Question 61 pts

What is wrong with the following function?

def kilometers_from_miles(miles):
    """Convert a value in miles to kilometers
    and return the kilometers value.
    """
    miles = float(input("Please enter a distance in miles: "))
    km = miles * 1.60934
    return km

Group of answer choices

The function has no parameters.

The function redefines its parameter.

The function is too short.

The function doesn't return a value.

6) Question 71 pts

What is wrong with the following function?

def torus_volume(inner, outer):
    """Compute and return the volume of a torus."""
    vol = 2 * (math.pi * inner) ** 2 * outer

Group of answer choices

The function has no parameters.

The function redefines its parameter.

The function is too short.

The function doesn't return a value.

Solutions

Expert Solution

PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU
AS I DONE MOST OF YOUR ANSWERS, THOUGH WE ARE ONLY ALLOWED TO ATTEMPT ONE ANSWER OR FOUR SUB PARTS, PLEASE GIVE IT A THUMBS UP

1) Within a function header, for example:

def gcd(a, b):

The variables that appear within parentheses are called what?

C) parameters

2) Within a function call, for example:

g = gcd(142, b);

The text that appears within parentheses is called what?

a) variables

3) Given this function header:

def compute(x, y, z):

And this code to call that function:

x = 7
result = compute(3, 2, x)

Within the function compute, what value will be stored in the parameter x ?

7

4)

What is wrong with the following function?

def area circle(radius):
    """Compute and return the area of a circle."""
    area = math.pi * radius ** 2
    return area

Group of answer choices

The function name includes a space character.

5)

What is wrong with the following function?

def kilometers_from_miles(miles):
    """Convert a value in miles to kilometers
    and return the kilometers value.
    """
    miles = float(input("Please enter a distance in miles: "))
    km = miles * 1.60934
    return km

The function redefines its parameter.

6)

What is wrong with the following function?

def torus_volume(inner, outer):
    """Compute and return the volume of a torus."""
    vol = 2 * (math.pi * inner) ** 2 * outer

The function doesn't return a value.


Related Solutions

Practice: Look at the following function header: def foo(a, b, c, d, e) answer the following...
Practice: Look at the following function header: def foo(a, b, c, d, e) answer the following questions: How many parameters this function has What is the name of this function If we call the function like this foo( 3, 2, 1, ‘c’, “Wdu”) what values will be assigned to a, b, c, d, e ? If we call function like this foo( 3, 2, 1, ‘c’, “Wdu”) what will be data types of a, b , c, d, and e.
Please use python3 Create the function team_average which has the following header def team_average(filename): This function...
Please use python3 Create the function team_average which has the following header def team_average(filename): This function will return the average number of games won by the Red Sox from a text file with entries like this 2011-07-02 Red Sox @ Astros Win 7-5 2011-07-03 Red Sox @ Astros Win 2-1 2011-07-04 Red Sox vs Blue Jays Loss 7-9 This function should create a file object for the file whose name is given by the parameter filename. If the file cannot...
The header of a Python function is shown below: def result(one, two, three = 3, four)...
The header of a Python function is shown below: def result(one, two, three = 3, four) (a) How do we call the situation with the third parameter in this header? (b) Indicate the method of correspondence between formal and actual parameters that is used in the following function call: result(four = 14, two = 22, one = 1, three = 33) (c) Explain what is wrong with the following function call: result(14, four = 44, 2, 3)
java euclidean algorithm (1) Let a = 35, and b = -49. Please compute GCD(a, b)....
java euclidean algorithm (1) Let a = 35, and b = -49. Please compute GCD(a, b). (2) Let a = 52, and b = 3. Please compute the quotient and remainder of a/b. (3) Let a = -94, and b = 7. Please compute the quotient and remainder of a/b. (4) Let a = 123, and b = 22. Please compute a mod b. (5) Let a = -204, and b = 17. Please compute a mod b.
Please fix all the errors in this Python program. import math def solve(a, b, c): """...
Please fix all the errors in this Python program. import math def solve(a, b, c): """ Calculate solution to quadratic equation and return @param coefficients a,b,class @return either 2 roots, 1 root, or None """ #@TODO - Fix this code to handle special cases d = b ** 2 - 4 * a * c disc = math.sqrt(d) root1 = (-b + disc) / (2 * a) root2 = (-b - disc) / (2 * a) return root1, root2 if...
Copy-paste the given function header (with or without the docstring) into the answer window and then...
Copy-paste the given function header (with or without the docstring) into the answer window and then complete the body of the function. Then below, write the call expressions that match the given test cases, printing out the returned results of each call expression. For full marks: def centre_align(s: str) -> str:     """ Returns a string that contains s "centred" and "highlighted"         when it is displayed on a single line on a typical screen.         Highlighting is to be...
Please answer using python 3 and def functions! Lab 2 Drill 3: (function practice) create and...
Please answer using python 3 and def functions! Lab 2 Drill 3: (function practice) create and use a function named highest() that takes three inputs and returns the highest number. After you have got it working, try calling the function with inputs ‘hat’, ‘cat’, ‘rat’.
Suppose a > b are natural numbers such that gcd(a, b) = 1. Compute each quantity...
Suppose a > b are natural numbers such that gcd(a, b) = 1. Compute each quantity below, or explain why it cannot be determined (i.e. more than one value is possible). (a) gcd(a3, b2) (b) gcd(a + b, 2a + 3b) (c) gcd(2a,4b)
Please answer all questions: 1)Write the formula for the updating function mt+1 = f(mt) in the...
Please answer all questions: 1)Write the formula for the updating function mt+1 = f(mt) in the following scenario, and then find the solution function mt = f(t). During a particularly dry season, the volume of water in a lake increases by 3% each day from precipitation, and then 8% of the volume of water is removed through a river. On day t0, the lake has 20,000 acre feet of water. 2)Use the solution function from the above example to determine...
Please answer within the hour Deal ONLY with the facts provided in the scenario for all...
Please answer within the hour Deal ONLY with the facts provided in the scenario for all problems, and determine the direct effects of the scenario ONLY in the current period. Assume no effect on the market price of stock. Assume the Current Ratio prior to any scenario was 2:1. 1a. Determine the effect of the following scenario on the Current Ratio: "A company pays a cash salary to one of its employees in the current accounting period for work performed...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT