Programming Flashcards Preview

Computer Science IGCSE > Programming > Flashcards

Flashcards in Programming Deck (10)
Loading flashcards...
1
Q

= vs. ==

A

= is assignment

== is comparison or equality

2
Q

Loops

A

condition-controlled loops:
pre-conditioned is a WHILE loop
post-conditioned is a DO…UNTIL loop

count-controlled loops:
for loop (for counter in range)
3
Q

constant vs. variable

A

value that does not change throughout code and remains “constant”
variable can change throughout the code based on input etc.

4
Q

Data types

A

char is a single alphanumeric character
string is 2 or more alphanumeric characters
integer is a whole number value
float is a floating point or decimal number
boolean is a true/false, yes/no or on/off value

5
Q

Programming constructs

A

Assignment:
an assignment statement allows us to place a value inside a variable

Sequence:
the order of programming statements
eg. must input name before printing

Selection:
making decisions in code or the occurrence of something as the result of a previous result or statement
eg. if statements

Iteration:
repeating or looping one or more lines of code
eg.
for loop
while loop
do while/until loop
6
Q

Data validation

A

Main: Range, Type and Presence

Range check:
check for data input to between a minimum and maximum value (limit looks for only min or max)

Length check:
check that number of characters doesn’t exceed or precede a certain value (usually for strings or passwords)

Type check:
check that data input is the correct data type

Presence check:
checks that input has been received

Format check:
check for input in certain format (date in dd/mm/yy)

7
Q

Flowchart symbols

A

Terminator (start/end) = rounded square/oval
Input/Output = parallelogram
Process = rectangle
Decision = Diamond

8
Q

Operators:

Arithmetic:
\+
-
*
**
/
//
%
Assignment:
\+=
-=
*=
/=
%=
**=

Boolean:
“and”
“or”
“not”

Relation:
<
> 
<=
>=
==
!=
A
Arithmetic:
\+  addition 
- subtraction 
* multiplication 
** exponent 
/ Floating-point division (e.g. 5 / 2 = 2.5 ) 
// Floor division (e.g. 5 // 2 = 2 ) 
% Modulo division (remainder - e.g. 5 % 2 = 1 ) 
Assignment: 
\+= Additive assignment (x += 5 is the same as x = x + 5) 
-= Subtractive assignment (x -= 5 is the same as x = x - 5) 
*= Multiplicative assignment (x *= 5 is the same as x = x * 5) 
/= Divisive assignment (x /= 5 is the same as x = x / 5) 
%= Modulus assignment (x %= 5 is the same as x = x % 5) 
//= Floor-division assignment (x //= 5 is the same as x = x // 5)
**= Exponential assignment (x **= 5 is the same as x = x ** 5) 

Boolean:
“and” All conditions must be True
“or” Only one of the conditions needs to be True
“not” Gives us the inverse (opposite) of the value being evaluated

Relational: 
< Less than 
> Greater than 
<= Less than or equal to 
>= Greater than or equal to 
== Equality (in a condition) 
!= Not equal to
9
Q

Data type conversions

A

Everything typed into a computer console is seen as a string

str() converts value in brackets into a string
int() converts value in brackets into an integer
float() converts value in brackets into a floating point

10
Q

Totalling vs. counting

A

Totalling adds values together , it totals or sums values

Counting counts the number of values, it counts repetitions

totalling eg.
totalWeight += itemWeight

counting eg.

itemCount += 1