SLR 2.2 Programming Techniques Flashcards
What is iteration?
‘iteration’ is repeating the same code more than once (looping).
Iteration is one of three main constructs in programming
What type of programming construct is demonstrated by the following pseudocode:
for i=0 to 7
print(i)
next i
This is an example of iteration
How many times would the following pseudocode print?
for i=0 to 7
print(i)
next i
8 times - 0 1 2 3 4 5 6 7
What would the following pseudocode do?
for i=0 to 7
print(i)
next i
it would print the numbers 0 1 2 3 4 5 6 7
Which programming construct is shown by the following pseudocode?
if entry == ”a” then print(“You selected A”) elseif entry == ”b” then print(“You selected B”) else print(“Unrecognised selection”) endif
This is an example of selection
Which programming construct is shown by the following pseudocode?
while answer!=”computer”
answer=input(“What is the password?”)
endwhile
This is an example of iteration
What does the following pseudocode do?
while answer != ”computer”
answer=input(“What is the password?”)
endwhile
repeatedly asks the user to input the password until they enter “computer”
Is the user automatically shown the request for the password to be entered?
while answer != ”computer”
answer=input(“What is the password?”)
endwhile
no - if the variable answer is already == “computer” then the request is not shown.
What is the condition to trigger the request for the password to be entered?
while answer != ”computer”
answer=input(“What is the password?”)
endwhile
if the variable answer is not equal to “computer”
What is sequence?
‘sequence’ is about the ordering of the steps in an algorithm.
sequence is one of 3 main constructs in programming.
Which programming construct is shown by the following pseudocode?
print(“Welcome to my program”)
username = input(“What is your username?”)
password = input(“What is your password?”)
sequence
What is an integer?
A data type that represents whole number values
What is a real?
A data type that represents number values that contain decimal points
What is a Boolean?
A data type that represents only True or False (these are sometimes used to represent on/off or yes/no)
What does alphanumeric mean?
Either a letter or a number