Programming Flashcards
(69 cards)
MOD
Remainder of division
DIV
Answer without remainder
Subprogram
Large program broken down into smaller subprograms.
Focus on specific function
Help decompose complex programs
Return in subprograms
Send value (perhaps a variable only in the subprogram ) back to line where function was called on- so it can be used on the line
Ie: to be printed
Two types of subprogram
Function
Procedure
Function
Subprogram that returns a value (using return)
Procedure
Doesn’t return value
Advantage of using subprograms
Breaks down complex problems into smaller parts- easier to design and test
Each can be tested separately and use abstraction to simply the problem
Reuse the code, quicker to develop other programs
Avoids code repetition, shorter programs (which are easier to develop and maintain and debug)
Split work between different programmers to work on different subprograms at a time.
Array
Static data structure, hold fixed number of same data type elements
Python does not use array (uses lists)
How is an element in an array accessed?
Using it’s index (location number)
Usually starts at 0
Static data structure
Fixed number of elements (cannot be resized)
Elements can change
Dynamic data structure
Memory efficient and not fixed capacity
Number of data items is only constrained by overall memory allocated to program
How to transverse an array?
Transverse (‘move through’)
Use for loop
For I in Array:
Print (I)
How to add a value to an array?
Cannot change amount of elements, change value of already existing element
Array[3] = “change”
Remember the 3 is the 4th value
How to delete a value from an array?
Fixed size so cannot delete value but overwrite as blank
Array[2] = “ “
The 2 is the 3rd value
How to search for value in an array?
Use for loop and see if equal to item
For value in Array:
If value == “change”
Print(value)
What is a two dimensional array
Same data type but multiple rows and columns
How to measure in two dimensional array?
Row first, then column
Row (down), column (across)
How to search two dimensional array?
Print(Array[3][5])
Prints 5th column on 3rd row
x,y,z,a,(3,5)
That’s the 3rd row, 5th column
Record
Store data of different types which are made of information of one person or thing
Each piece of information in the record is a field
Field (record)
A row name (piece of info)
What is a key field (records)?
Unique data that indentifies each record
How to present records and fields/database tables?
2D array
SQL
Structured query language