Comp SCI NWC Test 2

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

1/10

flashcard set

Earn XP

Description and Tags

Landon Van Berkuk, Based on quizzes 67 8

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

11 Terms

1
New cards


Interactive Loop

Will stop looping unless "told" to continue

2
New cards

Sentinel Loop

Will keep looping unless "told" to stop

3
New cards


Pre-Test Loop

May not loop at all, depending on initial conditions

4
New cards

Definite Loop

Knows exactly how many times it will iterate ahead of time

5
New cards

Indefinite Loop

Doesn't know how many times it will iterate

6
New cards

True or False: Tuples are ordered, but Dictionaries are unordered.

True

7
New cards

What will the following code print out?

x = 10

for i in range(1,4):

    x = x * i

    for k in range(1,4):

        x = x - k

print(x)

0

8
New cards

Given the following list of lists, which statement will access the 'X'?

table = [['O', 'O', 'O'],

         ['X', 'O', 'O'],

         ['O', 'O', 'O']]

table[1][0]

9
New cards

Consider the following code snippet. How many times will statement #1 be run?

x = 400

for i in range(5):

    for k in range(6):

        # Statement #1

        x = x - (i*k)

    # Statement #2

    x = x * i

5×6=30

10
New cards

Consider the following code snippet. How many times will statement #2 be run?

x = 400

for i in range(5):

    for k in range(6):

        # Statement #1

        x = x - (i*k)

    # Statement #2

    x = x * i

5

11
New cards

What does the following code snippet print out?

def recur(a, b):

    if a == 0:

        return b

    elif b == 0:

        return a

    else:

        return 1 + recur(a-1, b-1)

print(recur(4,6))

  1. 2+1+1+1+1=6.