2.2.3 - Additional programming techniques Flashcards
what does .length or len() do
Returns the length of the string
How to convert the whole string to uppercase or lowercase
.upper() and .lower()
What is concatenation and how is it done
- Joining two separate strings together
- Done using the “+” symbol
What does string[x:i] do
- Returns part of a string
- x represents the starting character
- i represents the end of the string (non-inclusive
What do .left(x) or .right(x) do
Returns the leftmost or rightmost character from a string
The number in the brackets shows how many characters to return
String commands to convert between ASCII and characters
- ASC()
- CHR()
what is a record in a database
Type of data structure that stores all of the data relating to one entity in a database
What is a database and why is it used
- A method to store data in an organised way (fixed structure)
- This allows easy finding and retrieval of the data needed
- It also allows multiple data types to be stored in the same record
How to recognise attributes and records in a database table
- Records are the rows
- Attributes are the columns
The 3 SQL commands in the order you have to use them
- SELECT (fields)
- FROM (database table)
- WHERE (criteria)
What does the wildcard * do in SQL
- SELECTs all fields
What does the wildcard % do in SQL
USED WITH LIKE
- Finds all records with characters like the example criteria
E.g. WHERE (criteria) LIKE “S%” finds all records beginning with S
What are subprograms and the different types of subprograms
- Small programs within a larger program that performs a specific task to produce structured code
- Procedure - performs a task and when it is done, the program continues where it left off
- Function - performs a task, maniuplates data and returns it back to the main program
Advantages of subprograms
- Saves time - can be saved as separate modules and used in other programs
- Small so easy to write, test and debug
- Shorter programs - can be called multiple times and only has to be written once
What is a global variable
Has a scope of the whole program. Is declared outside of a subprogram and in python, has to be declared before it is used in a subprogram