2.2 Programming fundamentals Flashcards
What are the 3 programming fundamentals
Sequence
Selection
Iteration
5 data types
Integer
Real
Float
Boolean
String
What is casting
Changing the data type of something
Cast 1 into int
int(“1”)
Cast 1 into true
bool(1)
Arithmetic operators
*
/
//
%
Assignment operator
=
What is a high-level language
Programming language used by humans
Has to be translated for computers to read
Comparison operators
==
!=
<
>
<=
>=
What is a constant
A variable that does not change
How to concatenate
newString= string1 + “ “ string2
What is concatenation
The conjoining of 2 strings
Example of string manipulation
.upper()
.left()
.length()
What are the boolean operators
And
Or
Not
Not and
Give an example of selection
if then
What does the switch statement do
If statement with one variable
What is sequence
When the code runs from top to the bottom
What is selection
Selects a certain part of the code to run depending on conditions
What is iteration
Looping code
Types of looping
Condition-controlled For
Count-controlled Do until, while
What does a for loop do
Loops for a certain amount of times
What does a do until loop do
Controlled by condition at the end of the loop
What does a while loop do
Control by condition at the start of the loop
Write a random number generator
roll = random(1,4)