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

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 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...
PLEASE POST A NEW ANSWER...NOT ONE THAT WAS ANSWER WITHIN THE FOLLOWING MONTH OR WITHIN THE...
PLEASE POST A NEW ANSWER...NOT ONE THAT WAS ANSWER WITHIN THE FOLLOWING MONTH OR WITHIN THE PAST YEAR. Thank You! What is the ethical dilemma in the Trump University case? What ethical framework did Trump use when arriving at his decision?
answer in c++ , Write the definition of the function NthOccurrence() whose header is int NthOccurrence(Array&...
answer in c++ , Write the definition of the function NthOccurrence() whose header is int NthOccurrence(Array& data,const T& value,int n) template It returns the index of the nth occurrence of value in data. If n is not positive, value appears less than n times in data or data is empty, it returns -1.
Show all work. Answers are given.Use double integrals to answer questions random variables A and B...
Show all work. Answers are given.Use double integrals to answer questions random variables A and B have joint probability density function given by fA,B (a, b) = ab + a + b + 1, −1 ≤ a ≤ 1, −1 ≤ b ≤ 0 Use double integrals to answer the questions (a) P(A ≤ ½). Answer is 9/16 (b) P(−½ ≤ A ≤ ½ , −½ ≤ B ≤ ½ ) Answer is ⅜ (c) P(A ≥ B + 1)...
Auditing Please answer with example A) What is the limitations of external audit. B) What is...
Auditing Please answer with example A) What is the limitations of external audit. B) What is the five fundamental principles as well as threats.? You should be able to explain not just writing in points else no full marks
(A) Let a,b,c∈Z. Prove that if gcd(a,b)=1 and a∣bc, then a∣c. (B) Let p ≥ 2....
(A) Let a,b,c∈Z. Prove that if gcd(a,b)=1 and a∣bc, then a∣c. (B) Let p ≥ 2. Prove that if 2p−1 is prime, then p must also be prime. (Abstract Algebra)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT