Pseudocode and Python Flashcards

1
Q

How to assign values to variables the add to those values then display them to the screen.

A

SET score TO 5
SET score TO score + 12
SEND score TO DISPLAY

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

How to concatenate strings ( join two or more strings together to make a new text string.)

A

SET displayName to firstName & surname.

use the ampersand

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

IF AND ELSE statements

A

IF condition THEN action END IF

IF condition THEN action_a ELSE action_b END IF

IF condition_1 THEN action_a ELSE IF condition_2 THEN action_b END IF

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

Complex Conditions

A

AND – both conditions must be true e.g. gender = “M” AND age > 18
OR – either of the conditions must be true e.g. class = 1 OR class = 3
NOT – the condition should not be true e.g. NOT (gender = “M”)

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

What is a Fixed Loop?

A

When a group of instructions is repeated a pre-determined number of times.
FOR counter 0 TO 5 DO
SEND “All work and no play makes Jack a dull boy” TO DISPLAY
End For

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

What is a Conditional Loop?

A
Will keep repeating a group of instructions until a specific conditional is met.
GET password FROM (STRING) KEYBOARD
WHILE password != “letmein” DO
    SEND “In-correct” TO DISPLAY
    GET password FROM (STRING) KEYBOARD
END WHILE
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the three Predefined functions?

A

Round – rounds a value to a specific number of decimal places.
SET pi TO 3.141592
SET pi TO ROUND (pi, 2) → the new value of pi will be 3.14

Length – give the number of character present in a variable.
SET word TO “Mississippi”
SET numWord TO LENGTH (word) → the value of numWord would be 11

Random – generates a random number, between a lower and upper range.
SET bonusBall to RANDOM (1,59)

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

What is the round predefined function?

A

Round – rounds a value to a specific number of decimal places.
SET pi TO 3.141592
SET pi TO ROUND (pi, 2) → the new value of pi will be 3.14

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

What is the length predefined function?

A

give the number of character present in a variable.
SET word TO “Mississippi”
SET numWord TO LENGTH (word) → the value of numWord would be 11

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

What is the random predefined function?

A

generates a random number, between a lower and upper range.

SET bonusBall to RANDOM (1,59)

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

A program must ensure the user enters a number between 1 & 100. Please write the code in pseudocode for this program.

A
GET score FROM (INTEGER) KEYBOARD
WHILE score < 1 or score > 100 DO
    SEND “In-Valid” TO DISPLAY
    GET score FROM (INTEGER) KEYBOARD
END WHILE
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

A program must calculate the total cost of 5 items. Please write the code in pseudocode for this program.

A
SET total TO 0
FOR counter 0 TO 5
    GET itemPrice FROM (REAL) KEYBOARD
    SET total = total + itemPrice
END FOR
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A program is required to count all A grades. Please write the code in pseudocode for this program.

A
SET grade TO [A, B, C, A, A, B, A, C]
SET numA TO 0
FOR counter 0 TO 7
    IF grade[counter] == “A” THEN
         numA = numA + 1
END FOR
How well did you know this?
1
Not at all
2
3
4
5
Perfectly