Term 2 | Practical | Chapter 3 Flashcards
What does a variable refer to in IT?
A variable refers to a memory location that can store data of a particular
data type. Just like variables in Mathematics, variables in programming
can only hold one value at a time.
What symbol do we use to indicate that the variable is a string
Single Quotation
‘ ‘
Fill in the blanks
______represents a single character, such as a letter, symbol or digit.
Char
What is the purpose of integer in coding
Integers can be used in numerical calculations
eg
5
-85
What is a real number?
A real number is a positive or negative decimal number. You can perform numerical calculations on real numbers. For Example:
- 68.9
5. 0
What is a Boolean?
A Boolean value can only be one of two values, that is, it can either be True or False. This is often used in programs
where a specific task is only complete if a specific condition is met.
NOTE:
● Boolean values are not included in single quotation marks because they are not strings.
Which one is a real number?
-7 OR 5.6
5.6
What is a string?
a. a type of variable that hold data values made up of ordered sequences of
characters
b. a data type that holds letters
c. a type of variable that hold characters
C
Variable names should use CamelCase. What does this mean?
This means the first word or letter is in
lowercase, and each word afterwards starts with an uppercase letter, for
example, rAmountPaid
What are the naming conventions for componets
●component names should describe the task they will
perform or the data
they will hold
● names should use CamelCase.
● component names should start with a three letters prefix that describes the
component type.
Before you can use a variable in Delphi, what should you do?
You must first tell delphi to reserve a space for it, In other words, declare a varaible
The____statement is used to tell Delphi that variables will be declared
var
True OR False
Multiple variables of the same type can be declared on one line, as long as
they are separated by commas
True
How do you declare a component?
You don’t. When you place a component onto a form, Delphi automatically inserts the declarations in the Type
section of the code.
What do you call this symbol?
:=
Assignment operator
On a line 69 a variable was declared, then on line 200 the variable was declared again.
69) iNumber:= 80;
200) iNumber:= 800;
What is the value of iNumber, and Why?
800 because When a new value is assigned the previous value is overwritten/replaced.
Why do we need to convert data types?
When data or values are read from an Edit
component, it is always of type string. This
poses a problem when you want to enter
numeric values that will be used in calculations.
You can also convert between different data types. This conversion process is
called_______
casting
StrToInt
Describe this conversion function
AND
Provide and Example
Converts a string value to an integer
value.
iNum := StrToInt(‘500’);
iAge := StrToInt(edtAge.text);
Describe these Conversion Functions
StrToFloat
IntToStr
FloatToStr
Converts a string to a real number
Converts an integer value to a string value
Converts a real value to a string value
What are the 3 types of errors?
● syntax errors
● runtime errors
● logic errors.
What are Syntax Errors?
Syntax refers to the form and structure of the programming language, which
defines how the symbols and keywords must be combined to format a statement.
In Delphi, the compiler checks your code against this rule. If the compiler does
not understand the statement, then a syntax error is reported.
Give 3 common syntax errors?
Common syntax errors include:
● leaving out a semicolon at the end of a statement
● we use a ‘begin …end’ block when grouping statements. Leaving out either
the begin or the end will result in a syntax error
● leaving out the command, var, when declaring variables
● assigning a variable using the equals to sign (=) instead of the assignment
operator (:=)
● misspelling variable names
● using keywords as variable names
● using variables that have not been declared
● not surrounding string values with the single quote marks.
For syntax errors, the 1._____ will generally warn you that you have made a mistake
and indicate the line in which the mistake occurs. Delphi will provide you with
information about the error in the 2._____ at the top left or the Messages
panel at the bottom of the Code screen
- IDE
2. Structure Panel