If Statements Flashcards

1
Q

what is the purpose of an if statement?

A

allows a program to carry out different actions depending on the nature of the data to be processed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what are compound statements?

A

spans multiple lies and consists of a header and a statement block and requires a colon (ex if statement)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is a statement block?

A

group of one or more statements all indented to the same coloumn

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how are if statements read?

A

instruction are executed if true or skipped if the condition is false`

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what are relational operations? how are they read?

A

comparing two values usually used in if statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is the difference between assignment and equality testing?

A

assignments makes something true while equality testing checks if something is true

floor = 13 vs if floor == 13

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is lexicographical order?

A

coming strings in ‘dictionary’ like order

  1. all uppercase letters comes before lowercase
    ‘space’ comes before all other 2. printable character
  2. digits come before all letters
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what elif statements?

A

else if
–> as soon as one of the test conditions succeeds the statement block is executed
–> if none of the test conditions succeed the final else clause is executed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is a boolean variable

A

often called a flag because it can either be up (true) or down (false)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what are the two boolean operators?

A

and, or
–> used to combine multiples conditions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what happens the operator “and” is used?

A

BOTH SIDES OF AND MOST BE TRUE FOR THE RESULT TO BE TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What happens if the operator “or” is used?

A

either or both conditions must be true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how is the boolean operator “not” used?

A

to invert the comparison

or

checking inequality (substitute !=)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is short circuit evaluations?

A

boolean operator “and”
–> evaluate conditions from left to right, if one is false then no need to continue

boolean operator “or”
–> if the left half of the “or “is true no need keep looking

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the “in” operator?

A

used to analyze strings
–> see if a substring is inside of the string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what is the inverse operator to “in”

A

“not in”