Data and Variables Flashcards

1
Q

What is this called?

  • All the text, numbers, and other information that are
    processed by a computer
  • Stored in variables in memory
A

Data items

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

What are the 3 different forms of data items?

A
  • Variables
  • Literals, or unnamed constants
  • Named constants
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Working with Variables

___________ are known as:
- Named memory locations
- Contents can vary or differ over time, holds just one value, can be used repeatedly with different values

A

Variables

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

Working with Variables

____________ is a statement that provides a data type and an
identifier for a variable. It is an act of introducing a variable to the complier

A

Declaration

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

Working with Variables

____________ is known as:
- Variable’s name
- names given to a variable

A

Identifier

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

Working with Variables

This is the classification that describes:
- What values can be held by the item
- How the item is stored in computer memory
- What operations can be performed on the data
item

A

Data type

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

Working with Variables

What data type represents whole numbers (e.g. -4, 0, 10)

A

Integer

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

Working with Variables

What data type represents fraction or decimal numbers? (e.g. 76.6, 0.001, 95.5)

A

Float

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

Working with Variables

What data type represents a character (e.g. Hello World)

A

String

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

Working with Variables

What data type represents logical true or false? (e.g. true, false)

A

Boolean

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

Working with Variables

What data type represents no data? (e.g. null)

A

Nothing

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

Working with Variables

This is the process of _____________ a variable:
- Declare a starting value for any variable
- an act of assigning a value to a variable

A

Initializing a variable

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

TRUE OR FALSE

The following code is initializing a variable:

string yourName = “Anna”

Working with Variables

A

TRUE

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

TRUE OR FALSE

The following code is initializing a variable:

num mySalary

Working with Variables

A

FALSE

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

Working with Variables

What term is used for the following?
- Variable’s unknown value before initialization
- Assign a value later
- Receiving one as input
- Placing the result of a calculation.

A

Garbage

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

In this process, the programmer chooses reasonable and
descriptive names for variables
- Some languages allow dollar signs or other
special characters
- Different limits on the length of variable names

A

Naming Variables

17
Q

Naming Variables

What are the 2 rules that Programming languages have for creating identifiers?

A
  • Most languages allow letters and digits
  • Some languages allow hyphens, underscore
18
Q

Naming Variables

What type of casing is this?
Variable names such as hourlyWage
that have a “hump” in the middle?

A

Camel casing

19
Q

Naming Variables

What are the 2 rules that variable names must use throughout the book?

A
  • Must be one word
  • Should have some appropriate meaning
20
Q

Naming Variables

The following code is an example of what type of casing?

HourlyWage

A

Pascal Casing

21
Q

What is the data item whose value cannot change during the program’s execution?

Understanding Unnamed, Literal
Constants and their Data Types

A

Constant

22
Q

What is the data item whose value cannot change during the program’s execution and has a specific numeric value?

  • Example: 43

Understanding Unnamed, Literal
Constants and their Data Types

A

Numeric constant (or literal numeric
constant)

23
Q

What are the string of characters enclosed within quotation marks known as?

Example:

“Amanda”

Understanding Unnamed, Literal
Constants and their Data Types

A

String constant (or literal string constant)

24
Q

What type of variable fits the following functions/definitions?
1. Holds digits
2. Can perform mathematical operations on it

Understanding Unnamed, Literal
Constants and their Data Types

A

Numeric Variable

25
Q

What type of variable fits the following functions/definitions?
1. Can hold text
2. Letters of the alphabet
3. Special characters such as punctuation marks

Understanding Unnamed, Literal
Constants and their Data Types

A

String Variable

26
Q

What type of variable fits the following functions/definitions?
1. Only if it is the correct type

Understanding Unnamed, Literal
Constants and their Data Types

A

Assign data to a variable

27
Q

What type of variable fits the following functions/definitions?
1. Similar to a variable
2. Can be assigned a value only once
3. Assign a useful name to a value that will never be changed during a program’s execution

Declaring Named Constants

A

Named constant

28
Q

What type of variable fits the following functions/definitions?
1. Unnamed constant
2. Purpose is not immediately apparent
3. Avoid this

Declaring Named Constants

A

Magic Number

29
Q

What type of statement fits the following functions/definitions?
1. Incorporated actions (assigned actions)

Example:

set myAnswer = myNumber * 2

Assigning Values to Variables

A

Assignment statement

30
Q

What type of statement fits the following functions/definitions?
1. Equal sign
2. Always operates from right to left

Assigning Values to Variables

A

Assignment operator

31
Q

Are the following statements valid or invalid?

set someNumber = 2
set someNumber = someOtherNumber

Assigning Values to Variables

A

Valid

32
Q

What are the 5 standard arithmetic operators?

Performing Arithmetic Operations

A
    • (plus sign)—addition
  1. − (minus sign)—subtraction
  2. (asterisk)—multiplication
  3. / (slash)—division
  4. % (percent) - modulo
33
Q

This rule is also called the order of operations

  1. Dictate the order in which operations in the same statement are carried out
  2. Expressions within parentheses are evaluated first

Performing Arithmetic Operations

A

Rules of precedence

34
Q

In the rules of precedence, these order of operations are followed from which direction?

Multiplication, division and modulo are evaluated next from?
Then, Addition and subtraction are evaluated next from?

Performing Arithmetic Operations

A

Left to right

35
Q

In this associativity,

Operations with the same
precedence take place
from left to right

Performing Arithmetic Operations

A

Left to right associativity