Question

In: Computer Science

Part1: 1.An algorithm is . a) a series of actions that solve a particular problem. b)...

Part1:

1.An algorithm is .

a) a series of actions that solve a particular problem.

b) an english description of a problem to be solved.

c) the process of converting between data types.

d) None of the above.

2. Program control is best defined as .

a) the degree of control a program has over the computer on which it is executed.

b) the line of code that is executing at a given time.

c) the order in which a series of statements is executed.

d) None of the above.

3. Pseudocode is a(n) .

a) hybrid language of all object-oriented languages.

b) artificial language used to develop algorithms.

c) language used to translate from Python to assembly language.

d) None of the above.

4.Pseudocode is most comparable to .

a) C#.

b) C.

c) Pascal.

d) English.

5.Which of the following is a type of control structure?

a) declaration structure.

b) repetition structure.

c) flow structure.

d) All of the above.

6.A transfer of control occurs when a .

a) program changes from input to output, or vice versa

b) logic error occurs in a program

c) statement other than the next one in the program executes

d) None of the above

7.

The three types of selection structures are , and :

a) for , if , if /else .

b) for , while , if .

c) if , if /else , while .

d) if , if /else , if /elif /else .

8.

What capability does if /else provide that if does not?

a) the ability to execute actions when the condition is false.

b) the ability to nest structures.

c) the ability to stack structures.

d) None of the above.

9.

Python prints a(n) when a fatal logic error occurs.

a) logic message.

b) traceback.

c) exception.

d) None of the above.

10.

Which of the following results in a fatal logic error?

a) attempting to add numbers that have not been converted from string format.

b) dividing by zero.

c) forgetting a colon in an if structure.

d) All of the above.

11. Which of the following statements would cause a while structure to stop

executing?

a) 3 <= 11 .

b) !(7 != 14) .

c) 6 != 9 .

d) All of the above.

12.

In a(n) , the body of a while structure never stops executing.

a) syntax error.

b) fatal error.

c) infinite loop.

d) None of the above.

13. A can be used in a repetition structure to control the number of times a

set of statements will execute.

a) declaration.

b) counter.

c) controller.

d) None of the above.

14.

A can be used in repetition structures to indicate the end of data entry.

a) counter.

b) boolean.

c) sentinel value.

d) None of the above.

15. The expression a *= 4 is correctly represented by:

a) a = 4 * 4 .

b) a = 4a .

c) a = a * 4 .

d) None of the above.

16. Counting loops should be controlled with values.

a) floating-point.

b) integer.

c) string.

d) None of the above.

17. The function call produces the same sequence as range( 10 ) .

a) range( 1, 10 ) .

b) range( 10, 1 ) .

c) range( 0, 10, 1 ) .

d) None of the above.

18. The characters %21.2f indicate a floating-point value will be printed with

how many positions to the left of the decimal point?

a) 21.

b) 18.

c) 2.

d) 19.

19.

The statement, when executed in a while loop, skips the remaining

statements in the body of the structure and begins the next iteration of the loop.

a) continue .

b) break .

c) next .

d) None of the above.

20.

The logical and operator ensures that .

a) two conditions are true.

b) at least one condition is true.

c) two conditions are false.

d) None of the above.

21.

Python provides the operator to reverse the meaning of a condition.

a) opposite .

b) not .

c) reverse .

d) All of the above.

Part2:

1.The small, simple pieces that are used to construct programs are typically

referred to as .

a) components.

b) segments.

c) sections.

d) None of the above.

2. A function is invoked by a .

a) function call.

b) function header.

c) declaration.

d) None of the above.

3.

Variables declared in function definitions are variables.

a) global.

b) local.

c) constant.

d) None of the above.

4.

Functions are called by writing the name of the function followed by zero or

more enclosed in parentheses.

a) conditions.

b) arguments.

c) counters.

d) None of the above.

5.

Which of the following correctly calls the math module function sqrt with

a value of 36?

a) math(sqrt, 36) .

b) math.sqrt(36) .

c) math.sqrt = 36 .

d) None of the above.

6.

Which of the following is a correct function definition header?

a) def count (x,y) .

b) def count (x,y): .

c) count (x,y): .

d) None of the above.

7. _____is a Python value that represents null.

a) None .

b) Null .

c) Nothing .

d) None of the above.

8. The capability of random-number generation is provided in the module .

a) rng .

b) random .

c) rand .

d) None of the above.

9. A recursive function is a function that .

a) calls another function.

b) calls itself.

c) does not return a value.

d) None of the above.

10. Iteration uses a structure, whereas recursion uses a structure.

a) repetition, selection.

b) sequence, repetition.

c) selection, repetition.

d) selection, sequence.

11. A difference between recursion and iteration is that:

a) iteration involves an explicit repetition structure unlike recursion.

b) recursion is associated with a counter controlled repetition.

c) iteration cannot execute infinitely, like recursion.

d) None of the above.

Solutions

Expert Solution

1)

The answer is option a.

An algorithm is sequence of instructions that solve a particular problem.

2)

The answer is option c.

The program control is the order in which the series of statements are executed.

It is basically about how a program makes decisions and executes the statements.

3)

The answer is option d.

A Pseudocode is a general english language description of the steps in an algorithm.

This is mainly used and developed for the purpose of human reading.

4)

The answer is option d.

A Pseudocode is a general english language description of the steps in an algorithm.

This is mainly used and developed for the purpose of human reading.

Note:

Please see that as per the guidelines, we are allowed to answer maximum upto one question posted in a single question.

In case of multiple choice type questions, upto 4 questions can be answered.

Please post the remaining questions as another question for further help and assistance. Thank you.


Related Solutions

5. Design a dynamic programming algorithm to solve the following problem. Input: An array A[1, ....
5. Design a dynamic programming algorithm to solve the following problem. Input: An array A[1, . . . , n] of positive integers, an integer K. Decide: Are there integers in A such that their sum is K. (Return T RUE or F ALSE) Example: The answer is TRUE for the array A = [1, 2, 3] and 5, since 2 + 3 = 5. The answer is FALSE for A = [2, 3, 4] and 8. Note that you...
Using Java implement a searching algorithm to solve the following problem (please specify the searching algorithm...
Using Java implement a searching algorithm to solve the following problem (please specify the searching algorithm being used) Requirements Choose one problem with an algorithm and implement it. You should show and explain the result whatever you got. I recommend using N-Queen problem (at least N=8 or more) or any simple perfect games. For example, - N-Queen problem with hill climbing - N-Queen problem with simulated annealing - N-Queen problem with genetic algorithm - Tic-Tac-Toe with Minimax
Using Java implement a searching algorithm to solve the following problem (please specify the searching algorithm...
Using Java implement a searching algorithm to solve the following problem (please specify the searching algorithm being used) N-Queen problem with genetic algorithm Please use the N-Queen problem (at least N=8 or more) or any simple perfect games. Please provide a screenshot of output and please heavily comment the code. Thanks!
1) Solve the following problem graphically. Indicate (a) whether or not the problem is feasible, (b)...
1) Solve the following problem graphically. Indicate (a) whether or not the problem is feasible, (b) whether or not the problem has an optimal solution, and (c) whether or not the problem is unbounded. If there is a unique optimal solution, specify the variable values for this solution. If there are 2 alternative optimal solutions, give the values for three different optimal solutions. max 9x1 + 3x2 s.t. x2 ≤ 125   − x1 + 2x2 ≤ 170 3x1 + x2...
Objectives: Learn to analyze a computational problem and construct an algorithm to solve it Learn to...
Objectives: Learn to analyze a computational problem and construct an algorithm to solve it Learn to use sequential statements to build a basic program to implement the algorithm, using correct programming format Learn to use the scanf function to read and store values entered on the keyboard by the user, and the printf function used to display output results on the computer monitor Learn to convert math formulas into correct arithmetic expressions using variables, constants, and library math functions Learn...
An algorithm is classically defined as a finite series of steps which solves a problem. What...
An algorithm is classically defined as a finite series of steps which solves a problem. What are some types of instructions which occur in everyday life which would qualify as an algorithm? What are some everyday types of instruction which would NOT qualify as an algorithm
1. Purpose: Apply various algorithm design strategies to solve a problem, practice formulating and analyzing algorithms,...
1. Purpose: Apply various algorithm design strategies to solve a problem, practice formulating and analyzing algorithms, implement an algorithm. In the US, coins are minted with denominations of 50, 25, 10, 5, and 1 cent. An algorithm for making change using the smallest possible number of coins repeatedly returns the biggest coin smaller than the amount to be changed until it is zero. For example, 17 cents will result in the series 10 cents, 5 cents, 1 cent, and 1...
PART1 A. A particular fruit's weights are normally distributed, with a mean of 672 grams and...
PART1 A. A particular fruit's weights are normally distributed, with a mean of 672 grams and a standard deviation of 38 grams.If you pick 8 fruits at random, then 12% of the time, their mean weight will be greater than how many grams? Give your answer to the nearest gram. B. On the distant planet Cowabunga , the weights of cows have a normal distribution with a mean of 342 pounds and a standard deviation of 57 pounds. The cow...
How much time does an algorithm take to solve a problem of size n if this...
How much time does an algorithm take to solve a problem of size n if this algorithm uses 2n2 + 2n operations, each requiring 10-8 seconds, with these values of n? a) 10: b) 20: c) 50: d) 100
Solve boundary value problem, use the method of undetermined coefficients when you solve for the particular...
Solve boundary value problem, use the method of undetermined coefficients when you solve for the particular solution y'' + 2y' + y = e-x(cosx-7sinx) y(0)=0 y(pi) = epi
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT