Grok Worksheet 8: Iteration Flashcards

1
Q

What are four advantages of using iteration over manually entering repeated code? Or disadvantages of using repeated code?

A
  1. Without iteration there would be way more lines of code
  2. Without iteration coding is more tedious
  3. Without iteration coding is more error-prone
  4. Manual coding without iteration does not scale
  5. With iteration if the code changes then you need to make far fewer changes to the code.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe the *= operator.

A

c *= 2 is the same as c = c * 2

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

Describe the /= operator.

A

c /= 2 is the same as c = c / 2

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

Describe the += operator.

A

c += 2 is the same as c = c + 2

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

Describe the -= operator.

A

c -= 2 is the same as c = c - 2

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

Describe the //= operator.

A

c //= 2 is the same as c = c // 2

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

Describe the %= operator.

A

c %= 2 is the same as c = c % 2

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

Describe the **= operator.

A

c = 2 is the same as c = c2

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