Programming Fundamentals (Paper 2) Flashcards
What are the three constructs (ideas of programming) ?
Sequence, Selection, Iteration
They are used to control the flow of a program.
Sequence
Structuring code into a logical, sequential order.
Selection
Decision making using IF statements
Iteration
Repeating code using FOR or WHILE loops
(Iteration is the process of looping or repeating sections of a program.)
What is a constant?
constants cannot be altered while the program runs. e.g pi = 3.14159
What is a variable?
Variables can be altered while the program runs
e.g. x = 45
What are the two types of iteration?
count - controlled
condition - controlled
What does a count-controlled loop do ?
Count-controlled loops repeat the same steps a specific number of times, regardless
of the outcome.
(Using count-controlled iteration can lead to fewer programming errors and more flexible programs.)
What does a condition-controlled loop do?
A condition-controlled loop will keep repeating the steps over and over … and
over … and over … and over, until it gets a specific result.
What is it mean to assign a variable (assignment)?
Giving a variable a value
e.g. y = 24
What is an infinite loop?
Condition-controlled loops can be written to continue forever. This is known as an
infinite loop
Meaning of nesting?
When using
selection, the number of possible paths at a decision point can be increased by including one selection within another.
What is it meant by casting?
the conversion of one data type into another.
e.g. an integer may need to be continued to a string in order to be displayed as part of a message.
(str(68) returns “68”
int(“54”) returns 54)
What is an array?
An array is a data structure that can store a collection of data values all under one name.
E.g games = [“FIFA”,”Fortnite”,”GTA”]
Games is the array
Each piece of data in an array is called an element — each element can be accessed using its position (or index) in the array