2 Programming Flashcards
What is declaration?
Declaration is telling the computer what the identifier (name) should be and what type of data should be stored for a variable
What is assignment?
Assignment is changing the value stored inside a variable. The value stored must match the data type of the variable
What is input?
Input is collecting data, usually through the keyboard
What is input in pseudocode?
OUTPUT “enter [something]..”
variable = USERINPUT
What is output?
Output is putting data onto the screen, usually as text
What is output in pseudocode?
OUTPUT “text”
What are the data types?
Character Real String Integer Boolean
What is Character data?
Character data is a single letter of text data
Eg. ‘a’
What is Real data?
Real data is fractional numbers.
Eg. ‘0.55’
What is String data?
String data is text data.
Eg. “Hello”
What is Integer data?
Integer data is whole numbers.
Eg. ‘12’
What is Boolean data?
Boolean data is a true or false value.
Eg. ‘True’ or ‘False’
What does the type of data determine?
The type of the data determines how it is stored and what you can do with the data.
What is casting?
Casting is the process of converting data from one type to another.
What are the reasons for casting?
One of the most common reasons for casting is output.
Output must be formatted as a string, and so we may need to convert a certain piece of data to a string.
All input also comes as a string, and must then be converted to other data types.
How do you cast to a string?
Casting to a string can be done by using the str function
Eg. str(3) gives “3”
How do you cast to an integer?
Casting to an integer can be done using the int function. Eg. int(3.4) gives 3
How do you cast to a real?
Casting to a real can be done using the real function.
Eg. real(“3.4”) gives 3.4
What are operators?
Operators are symbols that represent a specific function within a program
What are the Arithmetic operators?
Integer division
Modulo operator
Basic Operators
What is the integer division operator?
The integer division operator returns the quotient (whole part) of a division.
Eg. 5 DIV 2 would give 2.
What is the Modulo operator?
The modulo operator gives the remainder of the division of two numbers.
Eg. 5 MOD 2 would be equal to 1.
What are the basic operators?
Addition is done using a + sign. Subtraction is done using a - sign. Division is done using a / sign. Multiplication is done using a * sign. Exponentiation is done using a ^ sign.
What is the relational operator?
Relational operators compare two values, and produce a True or False value.