Code definitions Flashcards
(19 cards)
What is a Variable?
A storage location, with a name, storing a single value at any one time that can be changed
What is a Constant?
A storage location, with a name, that stores one value at any one time and cannot be changed while the program is running
What is a nested loop?
A nested loop is a loop within a loop whereby the inner loop re-iterates depending on the outer loops status ( if it can re-iterate or if it has met its target )
What is a syntax error?
A problem with the language (not defined)
What is a Logical error?
The error does not produce the expected output
Name the three Programming constructs
Sequence, selection, iteration
What is sequence?
The order in which the program is executed
What is selection?
When the program makes decisions
What is iteration?
Repeating a set of code / instructions until a condition is met
What is a substring?
A part of a string (slicing)
What are the 2 subroutines?
Procedures and Functions
What is a procedure?
Completes a task but doesn’t return
What is a subroutine?
A block of code for completing a task
What is a function?
Completes a task and returns
What is a parameter?
A variable used to pass between functions or procedures
Name 4 benefits of using subroutines
- Makes the program shorter and easier to read
- You can test each procedure or function individually for the source of an error
- You can reuse the code instead of rewriting the whole code
- Large programs can be split into different subroutines
What are the 3 lines of code needed to save to a file?
file = open(‘filename.py’,’w’)
file. write(‘addedtext’)
file. close()
What is the difference between count controlled and condition controlled?
Condition controlled loops reiterate until a condition put in place is met whereas a count controlled loop repeats the set code a set amount of times
What are the advantages of bubble sort?
- Easy to use
-