Term 2 | Practical | Chapter 3 Flashcards

1
Q

What does a variable refer to in IT?

A

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.

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

What symbol do we use to indicate that the variable is a string

A

Single Quotation

‘ ‘

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

Fill in the blanks

______represents a single character, such as a letter, symbol or digit.

A

Char

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

What is the purpose of integer in coding

A

Integers can be used in numerical calculations

eg
5
-85

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

What is a real number?

A

A real number is a positive or negative decimal number. You can perform numerical calculations on real numbers. For Example:

  • 68.9
    5. 0
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a Boolean?

A

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.

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

Which one is a real number?

-7 OR 5.6

A

5.6

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

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

A

C

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

Variable names should use CamelCase. What does this mean?

A

This means the first word or letter is in
lowercase, and each word afterwards starts with an uppercase letter, for
example, rAmountPaid

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

What are the naming conventions for componets

A

●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.

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

Before you can use a variable in Delphi, what should you do?

A

You must first tell delphi to reserve a space for it, In other words, declare a varaible

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

The____statement is used to tell Delphi that variables will be declared

A

var

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

True OR False

Multiple variables of the same type can be declared on one line, as long as
they are separated by commas

A

True

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

How do you declare a component?

A

You don’t. When you place a component onto a form, Delphi automatically inserts the declarations in the Type
section of the code.

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

What do you call this symbol?

:=

A

Assignment operator

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

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?

A

800 because When a new value is assigned the previous value is overwritten/replaced.

17
Q

Why do we need to convert data types?

A

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.

18
Q

You can also convert between different data types. This conversion process is
called_______

A

casting

19
Q

StrToInt

Describe this conversion function
AND
Provide and Example

A

Converts a string value to an integer
value.

iNum := StrToInt(‘500’);
iAge := StrToInt(edtAge.text);

20
Q

Describe these Conversion Functions

StrToFloat
IntToStr
FloatToStr

A

Converts a string to a real number
Converts an integer value to a string value
Converts a real value to a string value

21
Q

What are the 3 types of errors?

A

● syntax errors
● runtime errors
● logic errors.

22
Q

What are Syntax Errors?

A

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.

23
Q

Give 3 common syntax errors?

A

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.

24
Q

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

A
  1. IDE

2. Structure Panel

25
Q

What is a runtime errors?

A

These errors occur when
the program is running. For example, when division is taking place, the user
enters a zero for the divisor, the computer will immediately give a runtime error
because division by zero is inadmissible.

26
Q

What are logic errors

A

most dif cult type of error to solve is a logic error. These errors
occur when there are errors in the logic of the program or algorithm. The program
compiles and runs correctly but produces the incorrect results.