12.05/12.06/12.07 - Assignments/Logic statements/Loops Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What does the following pseudocode do?
“INPUT Number”

A

It stores a value that is input in a variable with the identifier ‘Number’

Assigning a value

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

What does the following pseudocode do?
“NumOfGuesses <– 1”

A

Stores the value 1 in the variable with the identifier ‘NumOfGuesses’

Assigning a value

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

What does the following pseudocode do?
“NumOfGuesses <– NumOfGuesses+1”

A

It takes the value stored in ‘NumOfGuesses’, adds 1 to that value and then store the new value back into the variable ‘NumOfGuesses’

Updating a value

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

What does the following pseudocode do?
“Value2 <– Value1”

A

It takes the value in ‘Value1’ and copies it to ‘Value2’

Value in ‘Value1’ remains the same

Copying a value

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

How to swap the content of 2 variables?

A

We first need to store one of the values in another variable temporarily. Then we copy the content in the 2nd variable into the 1st variable. Then the content in the temporary variable is copied into the 2nd variable.

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

Why cant the content in 2 variables directly be swapped?

A

Beacuse the second value to be moved over written by the first value to be moved

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

What is a logic proposition?

A

A condition uses atleast one logic proposition. Logic propositions use the rational (comparison) operators

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

Conditions are either…

A

…True or False

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

How to form more complex conditions in pseudocode?

A

Using the logical operators
AND, OR and NOT

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

What are the 3 types of loops?

A
  1. REPEAT…UNTIL
  2. FOR…NEXT
  3. WHILE…ENDWHILE
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which type of loops should be used instead of REPEAT…UNTIL if the loop should not be executed at all certain points?

A

WHILE…ENDWHILE

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

Which loop type is suitable to use if the number of repetitions is known?

A

FOR…NEXT

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

Which loop type is suitable to use if the statement inside might never be executed?

A

WHILE…ENDWHILE

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