2.2 notes Flashcards
What is a constant?
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 do constants benefit programmers?
They allow modification of a program by changing one value rather than every instance of a value throughout the program.
What is a variable?
An area of memory with an identifier where data can be stored and can be changed during runtime.
What are the types of data that can be stored in a variable?
- Integer
- Character
- String
- Real/Float
- Boolean
What is the purpose of initializing variables?
To set a variable at the beginning of a program which can be changed.
What is an example of polymorphism?
The same thing can do 2 different things based on what it’s used for.
What does type-casting or casting do?
It allows the user to convert a string to an integer.
Fill in the blank: Inputs from the keyboard are always _______.
characters
What happens when casting to an integer?
It truncates the value (e.g., ‘5.7’ becomes 5).
What are output statements used for?
To output or print to the screen in runtime.
What is a sequence in programming?
Executing instructions in order one after the other.
What does selection (branching) mean in programming?
When a program will branch depending on certain conditions.
What is iteration (looping)?
Repeating sections of code.
What does the Arithmetic Logic Unit (ALU) perform?
- Arithmetic operations
- Logical comparisons
- Binary shifts
What is the meaning of the operator ‘+’?
Addition
What does the operator MOD do?
It divides the numbers and gives the remainder.
What is the purpose of Boolean operators?
To evaluate boolean conditions.
True or False: Strings are mutable.
False
What do you do to read data from a file?
Open the file as readable and read data until the end of the file.
What is a flag variable?
A variable we toggle true or false based on a condition.
What is the first step in using record structures?
Define the record structure - what fields will be in the record.
Fill in the blank: In databases, data is stored in ______.
records and fields
What is the SQL command to select fields from a database?
SELECT
What does the ORDER BY clause do in SQL?
Sets the result in an order determined by specified criteria.
What is a structured text file used for?
To store data and exchange it between applications.
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.
What is the purpose of the .write() function?
To write data to a file.