2.2 notes Flashcards

(27 cards)

1
Q

What is a constant?

A

An area of memory with an identifier that cannot change during runtime.

Makes a program easier to read and reduces the possibility of errors.

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

How do constants benefit programmers?

A

They allow modification of a program by changing one value rather than every instance of a value throughout the program.

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

What is a variable?

A

An area of memory with an identifier where data can be stored and can be changed during runtime.

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

What are the types of data that can be stored in a variable?

A
  • Integer
  • Character
  • String
  • Real/Float
  • Boolean
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of initializing variables?

A

To set a variable at the beginning of a program which can be changed.

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

What is an example of polymorphism?

A

The same thing can do 2 different things based on what it’s used for.

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

What does type-casting or casting do?

A

It allows the user to convert a string to an integer.

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

Fill in the blank: Inputs from the keyboard are always _______.

A

characters

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

What happens when casting to an integer?

A

It truncates the value (e.g., ‘5.7’ becomes 5).

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

What are output statements used for?

A

To output or print to the screen in runtime.

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

What is a sequence in programming?

A

Executing instructions in order one after the other.

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

What does selection (branching) mean in programming?

A

When a program will branch depending on certain conditions.

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

What is iteration (looping)?

A

Repeating sections of code.

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

What does the Arithmetic Logic Unit (ALU) perform?

A
  • Arithmetic operations
  • Logical comparisons
  • Binary shifts
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the meaning of the operator ‘+’?

A

Addition

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

What does the operator MOD do?

A

It divides the numbers and gives the remainder.

17
Q

What is the purpose of Boolean operators?

A

To evaluate boolean conditions.

18
Q

True or False: Strings are mutable.

19
Q

What do you do to read data from a file?

A

Open the file as readable and read data until the end of the file.

20
Q

What is a flag variable?

A

A variable we toggle true or false based on a condition.

21
Q

What is the first step in using record structures?

A

Define the record structure - what fields will be in the record.

22
Q

Fill in the blank: In databases, data is stored in ______.

A

records and fields

23
Q

What is the SQL command to select fields from a database?

24
Q

What does the ORDER BY clause do in SQL?

A

Sets the result in an order determined by specified criteria.

25
What is a structured text file used for?
To store data and exchange it between applications.
26
What is the difference between storing data in arrays and databases?
Arrays are in main memory for use during execution, while databases are often on remote servers for shared access.
27
What is the purpose of the .write() function?
To write data to a file.