U2a - Programming Basics Flashcards
Define data type
The kind of values that can be used in a data item.
Name 5 data types
Integer, float/real, character, string, boolean
Define arithmetic operator
A symbol that will perform an operation on numbers e.g. +, -
What do constants look like?
They’re typically shown in uppercase and the words are separated with an underscore, eg. MIN_AGE
This is known as snake case.
Why declare a constant instead of a variable?
This prevents the value from being changed accidentally by a part of a code. It shows a programmer that the value should stay the same throughout the program.
Can a constant ever change its value?
A constant cannot be changed when the program is running. However, a constant can be changed by a programmer before the program is compiled or translated.
What is used to convert data types? (AKA Casting)
Functions
Why should you use comments in your programs? (3)
- To describe the purpose of the program
- To state the author of the program
- To explain what the code does
Define sequence
Statements are executed one by one in the order they are written
Define selection
An IF statement is a selection statement. The next statement to be executed depends on whether the condition being tested is True or False
Comparison operators
= equal to
=/ not equal to
> greater than
< less than
Define iteration
Iteration means repetition of a section of code
Three types of iteration statement
- FOR..ENDFOR
- WHILE…ENDWHILE
- REPEAT…UNTIL
When would you use a for loop
When you want to execute the loop a specific number of times
When would you use a while loop
When you want to execute the loop while a certain condition is true
When would you use a repeat until loop
When you want to execute the loop until a certain condition is true