2.2.3 - Additional programming techniques Flashcards

1
Q

what does .length or len() do

A

Returns the length of the string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to convert the whole string to uppercase or lowercase

A

.upper() and .lower()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is concatenation and how is it done

A
  • Joining two separate strings together
  • Done using the “+” symbol
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does string[x:i] do

A
  • Returns part of a string
  • x represents the starting character
  • i represents the end of the string (non-inclusive
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What do .left(x) or .right(x) do

A

Returns the leftmost or rightmost character from a string
The number in the brackets shows how many characters to return

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

String commands to convert between ASCII and characters

A
  • ASC()
  • CHR()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is a record in a database

A

Type of data structure that stores all of the data relating to one entity in a database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a database and why is it used

A
  • 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to recognise attributes and records in a database table

A
  • Records are the rows
  • Attributes are the columns
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The 3 SQL commands in the order you have to use them

A
  • SELECT (fields)
  • FROM (database table)
  • WHERE (criteria)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the wildcard * do in SQL

A
  • SELECTs all fields
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the wildcard % do in SQL

USED WITH LIKE

A
  • Finds all records with characters like the example criteria
    E.g. WHERE (criteria) LIKE “S%” finds all records beginning with S
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are subprograms and the different types of subprograms

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Advantages of subprograms

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a global variable

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a local variable

A

A variable that is declared in a subprogram and its use is confined to that subprogram

17
Q

What is an array

A

A static data structure that stores a number of related data items together in the same memory space (contiguous)

18
Q

Why are arrays used?

A
  • Allows for storage of more than one item of data under one identifier which reduces the need for variables
  • This makes the code shorter and therefore easy to debug or test