Concepts - Variables, Iteration, Functions Flashcards Preview

1 Computing AS Level (JoshH) > Concepts - Variables, Iteration, Functions > Flashcards

Flashcards in Concepts - Variables, Iteration, Functions Deck (15)
Loading flashcards...
1

What is a variable

Variables are storage areas within our programs. If we need to use data later on, it MUST be stored in a variable. Variables can be changed, so we can replace the data being stored at anytime.

2

What is a constant

Constants are like variable but CANNOT be changed after being set up. Python does not cater for Constants, so to indicate a Constant we use ALL CAPS. This tells the programmer to not change the value in this variable.

3

What is Declaration

Declaration or declaring a variable means to create the variable.

4

What is Assignment

Assignment means to add the data to the variable.

5

What is Iteration

Iteration is performing loops or repeating sequences of code.

6

What are the 2 types of iteration

There are 2 types of iteration:
Indefinite Iteration (condition controlled)
This is WHILE … ENDWHILE or REPEAT...UNTIL
Definite Iteration (count controlled)
FOR...ENDFOR

7

What are 2 properties of a 'while ... endwhile' loop

2 properties:
Boolean Expression
Test the expression at the start of the loop.

num ← RANDOM NUMBER (1,20)
guess ← 0
WHILE guess < > num
OUTPUT “Enter a Number”
guess ← INPUT
ENDWHILE

8

What are 2 properties of a 'repeat ... until' loop

Similar to WHILE
2 properties:
Boolean Expression
Test the expression at the END of the loop.

num ← RANDOM NUMBER (1,20)
REPEAT
OUTPUT “Enter a Number”
guess ← INPUT
UNTIL (guess == num)

9

What is a 'for ... end for' loop used for?

Used when you know how many times you are going to repeat something.
Uses Counting(stepping) Variable which could be integers or value from list.
FOR count ← 1 TO 12
PRINT count
ENDFOR

10

What is Nested Iteration

Loops within Loops:
FOR count ← 1 TO 10
FOR times ← 1 TO 10
PRINT count * times
ENDFOR
ENDFOR

11

What is a subroutine?

Subroutines can be functions or procedures. They are blocks of code that can be referenced and used anywhere in the program.

12

Define Built-in functions

These are functions that are pre-defined for the language you are using. ord() chr() len() are examples in python

13

Define Parameters

These are the variables that are created to bring data into a function or procedure. AKA arguments.
Found in brackets beside subroutine name and if multiple parameters, they are separated by a comma.

14

Define Local Variable’s

These are variables that are known only in the subroutine in which they are created or paramatised.

15

Define Global Variables

Global Variables
These are variables that are known throughout the program by all parts