Question

In: Computer Science

For the following function, what are the best types for the parameters (can be used for...

For the following function, what are the best types for the parameters (can be used for all parameters)? (best = will not cause errors, will compute what is intended.)

For example, if you select "string" that means that a call with 3 string values—add_and_mult("Hi", "bye", "llama") is a great choice.

def add_and_mult(num1, num2, num3):
    sub_val1 = num1 * 60
    sub_val2 = (sub_val1 + num2) * 60
    answer = sub_val2 + num3
    print("Wow! that's " + str(answer))

A. int

B. float

C. string

D. boolean

Solutions

Expert Solution

ANSWER: Here function given is computing answer which is used the operations like + , * which can be computed easily when you have integer or float numbers so here option (A) and (B) are best choices for this function. I also run your program you can see in the output when we are using string arguments it is giving output but not a good practice according to this function definition but you can also use String also.

OUTPUT WHEN ARGUMENTS AS FLOAT:

OUTPUT WHEN INPUTS ARE INTEGER:

OUTPUT when String inputs:


Related Solutions

Divide by classes. Parameters and return types of each function and class member function should be...
Divide by classes. Parameters and return types of each function and class member function should be decided in advance. Write a program that computes a patient's bill for a hospital stay. The different components are: PatientAccount Class Surgery Class Pharmacy Class main program Patient Account will keep total of the patient's charges. Keep track of the number of days spent in the hospital. Group must decide on hospital's daily rate. Surgery class will have stored within it the charges for...
What are the material parameters which can be used to increase the efficiency of CIGS (Copper...
What are the material parameters which can be used to increase the efficiency of CIGS (Copper indium gallium (di)selenide) solar cells? Parameters such as P+ or n+ layer, location of the recombination region, lattice mismatch etc. Please make point of parameters and describe them thoroughly.
C++ Write the implementation of the function concatenateIntArrays. This function receives 4 parameters in the following...
C++ Write the implementation of the function concatenateIntArrays. This function receives 4 parameters in the following order: An array of integer values (array1). An integer representing the size of array1 (size1). An array of integer values (array2). An integer representing the size of array2 (size). The function creates a dynamic array of integers of size size1+size2 to store all the values in array1, followed by all the values in array2. The function returns the pointer used to create the dynamic...
What types of information can variance analysis provide to the manager? How can it be used?...
What types of information can variance analysis provide to the manager? How can it be used? Give examples.
Write the following functions. Each function needs function comments that describes function and its parameters double...
Write the following functions. Each function needs function comments that describes function and its parameters double sphereVolume( double radius) double sphereSuface( double radius) double cylinderVolume( double radius, double height) double coneSurface( double radius, double height) double coneVolume( double radius, double height) That computes the volume and surface of the sphere with radius, a cylinder with a circular base with radius radius , and height height , and a cone with a circular base with radius radius , and height height...
The following equation can be used to compute values of y as a function of x:...
The following equation can be used to compute values of y as a function of x: ? = ?? −??sin(??)(0.012? 4 − 0.15? 3 + 0.075? 2 + 2.5?) where a and b are parameters. Write a Matlab script file (m file) with the following steps: Step 1: Define scalars a = 2, b = 5. Step 2: Define vector x holding values from 0 to π/2 in increments of Δx = π/40. Step 3: generate the vector y using...
C# Discussion question Why can reference parameters not be optional parameters? What are the conditions for...
C# Discussion question Why can reference parameters not be optional parameters? What are the conditions for generating ambiguous methods? What arethe differences between mandatory parameters and optional parameters? Explain the use of arguments in reference parameters, output parameters, and parameter arrays. Expalin overloading.
Why can reference parameters not be optional parameters? What are the conditions for generating ambiguous methods?
Why can reference parameters not be optional parameters? What are the conditions for generating ambiguous methods?
Identify the ways in which credit can best be used.
Identify the ways in which credit can best be used.
Describe assessment of heart function. Describe assessment parameters used for the vascular system, location of peripheral...
Describe assessment of heart function. Describe assessment parameters used for the vascular system, location of peripheral pulses and examination of jugular venous pressure.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT