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...
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...
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.
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?
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)...
(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)
please complete the header file that contains a class template for ADT Queue and complete all...
please complete the header file that contains a class template for ADT Queue and complete all the member functions in the class template. Submit the header file only, but please write a source file that tests all the member functions to make sure they are working correctly. queue.h #ifndef _QUEUE #define _QUEUE #include"Node.h" template<class ItemType> class Queue { private:    Node<ItemType> *backPtr;    Node<ItemType> *frontPtr; public:    Queue(); //Default constructor    Queue(const Queue<ItemType> &aQueue);    bool isEmpty() const;    bool...
Confidence Interval 1 All of the questions with the header "Confidence Interval 1" are based on...
Confidence Interval 1 All of the questions with the header "Confidence Interval 1" are based on the data in this problem. A researcher at the Annenberg School of Communication is interested in studying the use of smartphones among young adults. She wants to know the average amount of time that college students in the United States hold a smartphone in their hand each day. The researcher obtains data for one day from a random sample of 25 college students (who...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT