AP CSP

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

1/21

flashcard set

Earn XP

Description and Tags

unit 4

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

22 Terms

1
New cards

for loop

a for loop lets us repeat code a fixed number of times.

2
New cards

while loop

lets us repeat code as long as something is true.

3
New cards

condition

a condition is a code that you put inside an if statement or a while loop.

4
New cards

boolean 

true or false value.

5
New cards

if/else statement

Control structure that lets us run either one section of code or another depending on a test.

6
New cards

logical operator

used to make logical associations between boolean values.

7
New cards

comparison operator

used to make comparisons between values

8
New cards

randomize

to generate or select a random object.

9
New cards

break statement 

the break; statement breaks out of the current loop, without executing any more code in the loop. 

10
New cards

Iteration

repition of instructions a specified number of times, or until the condition is met.

11
New cards

if/else statements look like in code hs

  • if(condition == true){

Code to execute;

} else {

Code to execute;

}

12
New cards

correct syntax for loops

  • for(var i = 0; i < 10; i++){

Code to execute;

}

13
New cards

correct syntax for while loops

  • var count = 0;

while(count < 5){

println(count);

count = count + 1;

14
New cards

correct syntax for loops and a half

  • var SENTINEL = “abc123”;

while(true){

var password = readLine(“Enter your password”);

if(password == SENTINEL){

break;

}

}

15
New cards

when would you use a for loop?

when we want to repeat a line of code a fixed number of times

16
New cards

when should you use a while loop? 

When we do not know how many times a line of code should repeat

17
New cards

What causes an infinite loop?

When there is no ending condition of there is an ending condition that is impossible to meet.

18
New cards

how do you randomize a number?

var dice= Randomizer.nextInt(1,6);

19
New cards

How do you randomize a boolean?

var choice= Randomizer.nextBoolean();

20
New cards

how do you randomize a color? 

var rand color = Randomixer.nextColor();

21
New cards

truth table for &&

T && T = true

T && F = false

F && T = false

F && F = false

22
New cards

truth tables for || (or)

T || T = true

T || F = true

F || T = true

F || F = false