COMP 110 Quiz 02

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

1/20

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.

21 Terms

1
New cards
What does = mean?
Assignment (gives a variable a value)
2
New cards
Why is 18 = age invalid?
Can't assign to a number
3
New cards
What idea is in age = age + 1?
Reassignment using the old value
4
New cards
What happens with x = x + 1?
Updates x using its current value
5
New cards
If y = x and then y = y + 1, what's key?
Value is copied, not linked
6
New cards
After y = x, does changing x affect y?

No, y is already its own value

7
New cards
What does == mean (vs =)?
== checks equality, = assigns value
8
New cards
What does a while loop do?
Repeats code while the condition is True
9
New cards
Why is it called a 'loop'?
Program jumps back to the condition after each run
10
New cards
What must the while condition be?
A boolean expression
11
New cards
What happens when the condition is False?
Loop exits, next line after the loop runs
12
New cards
What happens if the condition is True?
Executes the loop block from the top
13
New cards
What happens after the last line in the loop block?
Goes back to check the condition again
14
New cards
Can anything go inside the loop block?

Yes: variables, print, if, even another while

15
New cards
How do you avoid an infinite loop?
Update something so the condition eventually becomes False
16
New cards

Is this correct for loops: 'make progress toward condition being True'?

No, must progress toward condition being False

17
New cards
Will the computer warn you about an infinite loop?

No, it'll run forever unless you stop it

18
New cards
Is 'if loop' correct terminology?

No, the correct term is 'while loop'

19
New cards
Can you use a while loop to go through a string?

Yes, use an index to go character-by-character

20
New cards
Should your counter be used as the index?

Yes, that's the typical method

21
New cards
What's the big benefit of loops?
Write small code that handles large data or repeated tasks