2.2 Programing Techniques Flashcards
What’s a variable?
Variables can change the data value that is assigned to them while the program is running.
-lower case first letter
What’s a constant?
A constant is an assigned data value at the design time of a program that can’t be changed. If you attempt to change the value of a constant in a program then the interpreter or compiler will return an error. It’s fixed for the duration of the program.
-CAPITALS for naming
What can data values be stored as?
Constants or variables
What’s the name of constant or variable linked to?
A memory location, that stores the data value. The size of the memory location depends on the data type.
What are the five main data types for programming languages?
Integer Real(or float) Boolean Character String
What’s a pseudocode representation, description and an example of an integer?
Pseudocode:INT
Description:Whole numbers only.
E.g: 0,928,-167
What’s a pseudocode representation, description and an example of an real(or float)?
Pseudocode:REAL
Description:Numbers that have a decimal part
E.g: 0.15,-5.78,10.0
What’s a pseudocode representation, description and an example of an Boolean?
Pseudocode: BOOL
Description: Can only take one of two values, usually TRUE or FALSE.
E.g: true/false, 1/0, yes/no
What’s a pseudocode representation, description and an example of an character?
Pseudocode:CHAR
Description:A single letter, number or symbol
E.g: D, o, 7, ;, €
What’s a pseudocode representation, description and an example of an string?
Pseudocode:STRING
Description:Used to represent text, it’s a collection of characters.
E.g: “€>ehruK3nj”
What’s the assignment operator?
=
It’s used to assign values to constants or variables.
-the name of the constant or variable on the left hand side of the =
-whatever your assigning should be on the right of the =
What do comparison operators do?
They compare the expression on the left hand side to the expression to their right hand side and produce a Boolean value.
What’re 6 comparison operators and what do they mean?
== :equal to <> or != :not equal to < :less than > :greater than <= :less than or equal to >= :greater than or equal to
What’s casting?
Languages have functions that allow you to manually convert between data types this is know as casting. This can be done using the int(), float(), bool(), str() commands.
What happens if you convert the integer 1 into a float?
It becomes 1.0
What happens if you change the integer 1 into Boolean?
It’s converted into the Boolean value True
What’s the exponential symbol, example and explanation?
Symbol:^ or **
Example: 2^3 =8
Explanation:it’s used to raise a number to a power