Programming Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

= vs. ==

A

= is assignment

== is comparison or equality

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

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

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

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

Flowchart symbols

A

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

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

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

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