COMP110 Quiz 01: Functions & Loops Definitions Study Set

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/39

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

40 Terms

1
New cards

You can use a while loop to iterate through each item in a collection. (T/F)

T

2
New cards

A parameter list is a part of the function's definition. (T/F)

T

3
New cards

There can be conditions such that the code block inside of a while loop won't run. (T/F)

T

4
New cards

What is the type of condition in the following while statement:

while condition:

bool

str

int

float

bool

5
New cards

When a function call is encountered, the return address "RA" is established in its frame before jumping to the first statement of the function's body (T/F).

T

6
New cards

Of the following, what does a function not do

abstract away processes

break larger programs into smaller sub-programs

define new data types

define new data types

7
New cards

Function calls are expressions that evaluate to a specific data type. (T/F)

T

8
New cards

If the condition in a while statement evaluates to _____, the program enters the repeat block and evaluate the first statement of the repeat block. (T/F)

T

9
New cards

When a function definition is encountered, the code block inside that function is run. (T/F)

F

10
New cards

print() and return perform identical commands. (T/F)

F

11
New cards

If the condition in a while statement evaluates to _____, the program exits the repeat block and continues to the next statement at the same level of indentation as the while keyboard. (T/F)

F

12
New cards

Defining a function is the same as calling it.

F

13
New cards

def flyer (w: int, x: str) -> int:

y: int = w + len (x)

return y

Which line(s) is a return type declared?

1

14
New cards

def flyer (w: int, x: str) -> int:

y: int = w + len (x)

return y

List the name of the function defined.

flyer

15
New cards

def flyer (w: int, x: str) -> int:

y: int = w + len (x)

return y

On what line(s) are parameters found?

1

16
New cards

Write a line of code to call the function defined above with the arguemnts 3 and "plane".

flyer(3, "plane")

17
New cards

iteration

one pass through a while loop

often "i" (or "idx") is used as the counter to track the loop

18
New cards

The while statement allows you to repeat a block of statements in your program. (T/F)

T

19
New cards

The while statement is called a loop, because the control of your program jumps back up to a point earlier in the program that the end of the repeat block. (T/F)

T

20
New cards

The condition in the while statement's syntax must be a bool expression (T/F).

T

21
New cards

If the conidtion in a while statement evaluates to False, the program exits the repeat block and continues to the next statement at the same level of indentation as the while keyboard. (T/F)

T

22
New cards

If the condition in a while statement evaluates to True, the program enters the repeat block and dvalutes the first statement of the repeat block. (T/F)

T

23
New cards

After the final statement of the repeat block is evaluated, the program jumps back up to the condition of the while statement and evaluates it again. (T/F)

T

24
New cards

You can write any statements you'd like inside of the repeat block, such as other print statements, variable declaration and assignemnt statements, conditional if-else statements, while loop statements, and so on. (T/F)

T

25
New cards

To avoid an infinite loop which of the following should be true:

Something must change in the repeat block taht cause the while loop's condition to change.

Forward progress must be made toward the while loop condition becoming True.

Forward progress must be made toward the while loop condition becoming False.

1, 3

26
New cards

Your computer knows when you write an infinte loop in your program and will not run your program if it sees it is doing pointless, endless work on your behalf. (T/F)

F

27
New cards

The phrase "if loop" is incorrect and should not be said. The phrase "while loop" is correct. (T/F)

T

28
New cards

You can use a while loop to iterate through each item in a collection. For example, a str is a collection of characters, and you can use a while loop to reason about each character one-by-one. (T/F)

T

29
New cards

When iterating through a collection using the index/subscription operator, such as with a string, it is common to use your counter variable as the index operator's int value in order to access individual items in the collection one-by-one. (T/F)

T

30
New cards

The big, valuable idea of a loop is that it allows you to write a fixed number of lines of code that can process arbitrarily sized amounts of data and/or computations. (T/F)

T

31
New cards

Functions are used for which of the following:

- Process abstraction

- Defining new data types

- Breaking larger problems into smaller sub-programs (task decomposition)

Process abstraction

Breaking larger problem into smaller sub-programs

32
New cards

Defining a function is the same a calling it. (T/F)

F

33
New cards

A function definition can be thought of as a specfication of the instructions which will be carried out when the function is called. (T/F)

T

34
New cards

Function definitions are found in which of the following ways:

Built-in functions automatically avilable

Imported from libraries

Defined in the same python file/module

All the above

35
New cards

Which of the following will appear in a valid functiona call expression?

the def keyword

the name of the function

an argument list

a parameter list

a function body

the name of the function

an arugment list

36
New cards

Which of the following will appear in a valid functiona definition signature?

the def keyword

the name of the function

an argument list

a parameter list

a function body

a return type preceeded by ->

ends with a :

def keyword

name of the function

parameter list

a return type preceeded by ->

ends with a :

37
New cards

Which of the following will appear in a valid functiona definition?

the def keyword

the name of the function

an argument list

a parameter list

a function body

a return type preceeded by ->

ends with a :

signature

signature

38
New cards

Each argument is an expression. (T/F)

T

39
New cards

The signature line tells anyone who wants to use a function what it needs in order to be called and what you can expect returned back as a result. (T/F)

T

40
New cards

Parameters are found in function definitions. Arguments are found in fucntion calls. (T/F)

T