Concepts - Variables, Iteration, Functions Flashcards

1
Q

What is a variable

A

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.

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

What is a constant

A

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.

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

What is Declaration

A

Declaration or declaring a variable means to create the variable.

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

What is Assignment

A

Assignment means to add the data to the variable.

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

What is Iteration

A

Iteration is performing loops or repeating sequences of code.

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

What are the 2 types of iteration

A

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

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

What are 2 properties of a ‘while … endwhile’ loop

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are 2 properties of a ‘repeat … until’ loop

A

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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a ‘for … end for’ loop used for?

A

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

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

What is Nested Iteration

A
Loops within Loops:
FOR count ← 1 TO 10
	FOR  times ← 1 TO 10
		PRINT count * times
	ENDFOR
ENDFOR
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a subroutine?

A

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

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

Define Built-in functions

A

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

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

Define Parameters

A

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.

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

Define Local Variable’s

A

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

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

Define Global Variables

A

Global Variables

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

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