week 5- advanced branching Flashcards

1
Q

diagram code should include

A

input, output, branches + conditions, and other processes

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

code style

A

readability, consistent naming conventions and file header comments

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

basic ranges

A

use elif statements to check different conditions and use and/or

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

should you compare floating point numbers with relational operators?

A

no

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

can relational operators compare strings?

A

yes, only == or != or you can use to compare lengths

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

how are strings compared

A

each number is converted to it’s ASCII value and characters are compared in order

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

how are lists/tuples compared

A

with priority to the 1st element to determine T or F

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

how are dictionaries compared

A

by key

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

membership operators

A

in and not in, checks for presence of specific values in container and returns T or F

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

substring

A

specific part of smaller string

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

‘abc’ in ‘yakabc’ returns

A

true

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

identity operators

A

is and is not, checks if operands reference the same object in memory

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

object identity

A

memory address of object

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

id(x)

A

checks object identity of x

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

precedence rule

A

pemdas, relational operators, not, and, or

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

common error

A

missing parenthesis, use them to improve readability and avoid mistakes

17
Q

code block

A

series of code grouped together, identified by indentation and new code blocks follow a statement ending in colon (:)

18
Q

if line is too long

A

you can wrap onto next line

19
Q

max characters per line

A

120, 80 is the recommended

20
Q

conditional expression

A

if and else in a single line, middle is evaluated first, best for assignment

21
Q

y = 0 if x<100 else x
what is y if x is 101?

A

x

22
Q

ternary expression

A

conditional expression with three operands (standard)