CS 122 final (Module 2)

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

A for loop inherently runs some undetermined number of times, until an exit condition is met.

false

A while loop steps through a predefined number of iterations.

false

Assume the following function exists folliowing this structure: function [A, B, C] = thisFunctionExample(someInput) And suppose that you want to "save" value B. To do so, you would call the function as follows: B = function(theInput)

false

True or False: Formally, functions take input via values, and provide output via parameters.

false

True or False: The workspace of a function is available to the user or the calling script/function at all times, during and after the function runs.

false

Which of the folloing is how we would structure a for loop in Matlab? Note: one or more may be technically correct, but how did we discuss the structure in class?

for i = startingNumber : endingNumber % do something end

Select all traits of both a for and while loop that we discussed in class. What of the following are true for all while and for loops?

-All for and while loops have a starting line that includes the condition test. -All for and while loops have an ending line. -All for and while loops have additional "stuff," or code, in the middle. -All for and while loops have an "exit strategy," or a means of determining it's time to stop looping.

A for loop steps through a predefined number of iterations.

true

A for loop steps through each iteration until some condition is met and causes it to exit.

true

A while loop inherently runs some undetermined number of times, until an exit condition is met.

true

A while loop steps through each iteration until some condition is met and causes it to exit.

true

As a good practice, the second line in your function should include: % the help info, % documentation on how to use the function, % what it does, % author information % and anything else relevant that the user of your function needs to know.

true

Assume the following function exists folliowing this structure: function [A, B, C] = thisFunctionExample(someInput) And suppose that you want to "save" all of the return values. To do so, you would call the function as follows: [A, B, C] = function(theInput)

true

Assume the following function exists folliowing this structure: function [A, B, C] = thisFunctionExample(someInput) And suppose that you want to "save" value A. To do so, you would call the function as follows: A = function(theInput)

true

True or False: All functions must include the function declaration, defining that a function is to follow. This looks like: function [values] = functionName(parameters)

true

True or False: Formally, functions create, and then destroy all variables used while running the function.

true

True or False: Formally, functions operate in their own workspace.

true

True or False: Functions allow us to take complex problems, and break them into smaller, and more manageable parts.

true

True or False: Functions can return output, passing information back to the user or other script/function that called it.

true

True or False: Functions can take input, which are passed to the functions as parameters.

true

True or False: The help function in Matlab will return the first block of comments in the file, which is typically put right after the function declaration.

true

True or False: We can write functions inside the Matlab editor window (or a seperate text editor).

true

We talked about two types of iterations, while and for.

true

When writing a function, we need to start with the following on the first line (assuming one input and one output): function [returnOne] = functionName(inputOne)

true

Which of the folloing is how we would structure a while loop in Matlab? Note: one or more may be technically correct, but how did we discuss the structure in class?

while (someCondition) % do something end


Kaugnay na mga set ng pag-aaral

Conceptual Physical Science Final Exam: Chapter 28: The Structure of Space and Time

View Set

GENERAL MATHEMATICS LESSON, SS1 ,WEEK ONE:ALGEBRAIC PROCESSES AND EXPRESSIONS.

View Set

Chapter 9 Muscles of the Trunk and Extremities

View Set