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?
The allocation of data values to variables, constants, arrays and
other data structures so that the values can be stored.
what is a variable
Value that can change during the running of a program. By
convention we use lower case to identify variables (eg a=12)
what is a constant?
Value that remains unchanged for the duration of the program. By
convention we use upper case letters to identify constants. (e.g. PI=3.141)
what are data structures?
a data structure refers to a way of organizing and storing data in a computer so that it can be accessed and used efficiently. e.g. arrays, 2-D arrays, data types.
what do we use to show indices in python? e.g. if someone wants to find out the answer to 2^3
2 ** 3, which equals 8
What is input?
Input is collecting data, usually through the keyboard
it is data sent to a computer to be processed
What is input in pseudocode and in python?
psuedocode:
name <— USERINPUT
python:
name = str(input(“Enter your name: “))
psuedocode: variable = USERINPUT
What is output?
Output is putting data onto the screen, usually as text
it is processed info that is sent out from a computer
What is output in pseudocode and in python?
psuedocode:
OUTPUT “text”
python:
print(“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 decimal numbers.
Eg. ‘0.55’
What is String data?
String data is text data (multiple characters).
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
Modulus/modulo operator
Basic Operators