2.2 Flashcards

1
Q

Variable

A

Value stored in memory that can change while the program is running

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

Constant

A

Value that does not change while the program is running, assigned when the program is designed

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

Assignment

A

Giving a variable/constant a value

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

Casting

A
  • Converting a variable from one data type to another
  • integer/character/string/float/boolean
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Input

A

Value read from an input device (e.g. keyboard)

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

Output (2)

A
  • Data generated by the computer
  • Displayed to the user
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

**

A

Exponential

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

%

A

Modulus (remainder)

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

//

A

Quotient

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

Boolean Operators

A
  • AND: both must be true (D logic gate with two inputs one output)
  • OR: either must be true (fish/kite logic gate with two inputs one output)
  • NOT: false (triangle with tip pointing right at a small dot with one input one output)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why is casting necessary? (2)

A
  • Softwares receive data in a format they are expecting
  • Manipulation of data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

3 stages to write data to a file

A
  • variable = open(‘filename.txt’, ‘a’) to append (OR to write do ‘w’)
  • variable.writeLines
  • \n = enter a new line
  • variable.close()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

3 stages to read data in a file

A
  • variable = open(‘filename.txt’, ‘r’) to read
  • variable2 = variable.readline()
  • print(variable2)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why do you need to close a file?

A
  • Releases the file handle and breaks the connection between it and program
  • variable.close()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What do you have to do once you have written to a file but want to read it (or vice versa)?

A
  • variable = open(‘filename.txt’, ‘r’) to read
  • variable = open(‘filename.txt’, ‘a’) to append (OR to write do ‘w’)
  • MUST do before cause that is just file handling rule
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

SQL Commands

A
  • SELECT: field to be returned (* = all)
  • FROM: which file
  • WHERE: certain condition (LIKE = wildcard)
  • ORDER BY: ASC or DESC
17
Q

Explain the two main types of sub programs

A
  • Procedures: carry out a task and provide structure to code (basically main.py)
  • Functions: carry out a task and return a value, creating reusable program components
18
Q

Advantages of Using Sub Programs (3)

A
  • Easier to write entire program (many can work on large program at the same time, cutting down development time)
  • Easier to debug (maintainability: can be tested separately)
  • Reusable components (could be gathered into library for use over multiple programs)
19
Q

What is a record?

A
  • Collection of related data items
    (could be different data types)
20
Q

Records stored in text files… (5)

A
  • Stored on secondary storage
  • Used to store data when the application if closed
  • Each entry is on a new line
  • May require linear search to find data
  • Structure text files (e.g. CSV) can be used to exchange stored data between applications
21
Q

Records stored in arrays and lists… (5)

A
  • Stored in main memory (RAM)
  • Used to store data when program is running
  • Single/multi-dimensional
  • Indexes refer to data items
  • Efficient algorithms are used to find data
22
Q

Array (5)

A
  • Thought of like a variable which can contain more than one data item
  • Allocating a contiguous part of memory to store data
  • Has same data type
  • Visualise as a column/table (two dimension)
  • Indexes start at 0
23
Q

What are the three basic programming constructs?

A
  • Sequence: executing one instruction after another, one by one
  • Selection: a program branch depending on a condition (IF)
  • Iteration: repeating code in a loop (counter (FOR)/condition (WHILE)) until a condition has been satisfied
24
Q

Advantages of local variables (2)

A
  • Self-contained within subroutine, can be used without variable names conflicting with those use in main (if a local and global variable have the same name, the local variable takes priority within the function
  • Memory efficient: memory space is created when the subroutine is executing, it will be released when the execution is finished