2.2 programming fundamentals Flashcards
What is an integer?
A whole number
What is real?
A number with decimals
What is boolean?
True or false
What is a character?
A letter, number or symbol in the given character set.
What is casting?
Changing the data type of a piece of data from one type to another.
What is a string?
A sequence of characters
What are the 3 programming constructs?
Sequence, selection and iteration
What is sequence?
All lines are executed
What is a selection?
Decisions made that determine the execution
What is iteration?
Code is repeated (‘looped’) until specified conditions are met.
What are the 2 types of iteration?
Count controlled loop
Condition loops
What is a variable?
a named data location in a program for a value that can be change during the program.
What is a constants?
They are named data which value remains the same throughout the program.
what does == mean?
equal to
what does != mean
not equal to
What does < mean?
Less than
What does <= mean?
less than or equal to
What does > mean?
more than
What does >= mean?
Greater than or equal to
What does * mean?
Multiple
What does / mean?
divide
What does MOD mean?
Modulus - outputs the remainder
What does DIV mean?
Quotient - divides but ignores the remainder only outputting the whole number.
What does ^ mean?
To the power of…
What is an assignment?
Giving a variable or constant a value
What is the advantage of using a constant?
It makes it easier to read the program and leads less chance of errors.
What are the 3 Boolean operators?
NOT, AND, OR
What must strings be written inside?
”” quotation marks
What does x.upper mean?
All the characters will be uppercase
What does x.lower mean?
All the characters will be lower case
What does x.length mean?
Returns the number of characters of the string
What does x.left(i) and x.right(i)?
This extracts the first/last parts of the string.
What does a.substring(a,b) mean?
Extracting a string starting at position a with length b from the string.
What does Concatenate mean?
To join them to form another string. Using the “+”
What does slicing mean? (string manipulation)
allows programmers to select any character from a string.
What are some of the basic file handling operators?
Open
Read
Write
Close
How do you open a file using file handling?
myfile = open(“file.txt”)
How do you read using file handling?
Oneline = myfile.readline()
How do you write in a file?
myfile= open(“Hello”.w)
How do you close a file using file handling?
myfile.close()