Variables Flashcards
What is a variable?
Named reference to a value which are stored in computer’s memory(memory locations)`
What is a declaration?
Statement used to define what data type a variable is going to be.
*Note that unlike in python, basic programming languages need to be told what data type.
Example: Declaration -> Num myNumber
vs
Python Example: x = 5 (python knows this is a numeric value as strings are in quotations)
What is an indentifer?
What we define the name of the variable
Example: area = x + 5 | Area would be the identifier
What is a data type?
Used to describe the variable we are indentifying
Example: num = numeric data type | num mySalary would output a numeric value.
What is initializing the variable?
Telling the starting value for a variable.
Example: myName = Khazer | Khazer would be the initialized varible
Garbage
Variable that is not yet declared. Programs that use it will result in a logic error
What is Camel Casing?
When the variable name starts with a lowercase and uses an uppercase letter to show distinction(separation) between words without the use of a space.
Example: myName
What is Pascal Casing?
When the variable name uses uppercase letters to show distinction between words.
Example: MyName
Integer
Whole numbers that can be positive or negative.
What is a String?
Data type that contains words
What is a Numeric?
Data type that contains a number
Floating-point
Data type that contains a decimal point
Numeric Constant
Value that doesn’t change. Example would be the value 5. Will always be 5
String Constant
Text Value that once in “ “ is not changeable
What are the Three Rules Variable Names should follow?
- One word(no spaces), but you are able to use hyphens or underscores.
- Must start with a letter