Programming Flashcards Preview

Computing > Programming > Flashcards

Flashcards in Programming Deck (43):
1

Explain the concept of a data type.

Variables have a data type that defines the type of data that will be stored at the memory location and the operations that can be performed on it.

2

List and describe the 5 common data types.

Boolean - has the value true or false.
Characters - single character, can be a letter, punctuation, digit, a space or symbol that can be typed
Integers - whole numbers
String - zero or more characters
Float - numbers with fractional parts

3

Describe how variable declaration is used in programs.

Variables are declared at the start of some programs, so that when the program runs, the appropriate amount of data can be reserved to store the data.

4

Describe how constant declaration is used in programs.

Constants are declared at the start of a program and then can be referred to as needed in the code.
+ when value changes, only have to edit in one place instead of looking for every place in the program where you used that value
+ Code will be easier to read and understand because the constant's identifier will be used instead of a number. This makes code easier to debug and maintain (later on).

5

Describe how assignment is used in programs.

In most programming languages, values are assigned to variables using an = sign.

6

Describe how iteration is used in programs.

FOR loop - definite iteration, count-controlled loop iterates the number of times specified in the loop.
WHILE loop - indefinite iteration, number of times loop will be repeated depends on loop condition being True. As soon as it becomes False, the loop terminates.

7

Describe how selection is used in programs.

Executes the next set of statements depending on the condition.

8

Describe the concept of a data structure.

Grouping data items together so they can be treated as a set of data.

9

What is an array?

A group of data items of the same data type, which is stored under one identifier (name) in contiguous (one after another) memory locations.

10

Describe how arrays (lists in Python) operate in programs.

Using an array can simplify a program by storing all related data under one name. This means that a program can be written to search through an array of data much more quickly than having to write a new line of code for every variable. This reduces complexity + length of program - makes it easier to find and debug errors.

11

What are text files?

Contain text that is in lines - there is no other structure.

12

Describe how programs read from a text file.

1) Tell program where the file is.
2) Open file to read from it (opens file with a pointer pointing to the first line).
3) Read a line/lines of text from the file (automatically will move pointer to next line).
4) Close the file.

13

Describe how programs write to a text file.

1) Open the file to write to.
2) Write each line of text to the file one at a time, until there is no more text to write.
3) Remember to close the file at the end.

14

Describe common string handling operations in a program.

Changing a string to an integer in python -
String manipulation - programming languages have built in functions to manipulate strings.

15

Describe random number generation in a program.

n m

16

Describe the concept of a subroutine.

A named, self-contained section of code that performs a specific task. May return one or more values, but doesn't have to. Can be used anywhere from the program as needed,

17

Explain the advantages of using subroutines.

Decomposing a large problem into sub-tasks and writing them as subroutines makes the problem easier to solve.
Each routine can be tested separately.
Can be used several times within a program.
Can be stored in a subroutine library + used in different programs if needed.
Programmers can get a large job done quickly by working on individual subroutines at the same time.
Easier to make changes if needed - program maintenance is easier.

18

Describe how parameters pass data around a program.

Makes subroutine more useful. Parameter is a variable named in the subroutine heading that will receive and use whatever value you pass.

19

What are the two different types of subroutines?

Procedures and functions.

20

Describe how procedures are used in programs.

Makes code shorter, simpler and easier to write.
To create, first give procedure a name - python uses statement def to name a procedure. Once procedure is named and written, it can be called at any point in the program.

21

Describe how functions are used in programs.

A function is just like a procedure, except that you wait to see what the result is.
Every function needs, a name, values that it needs to use for calculation, program code to perform the task and a value to return to the main program.

22

What is a procedure?

A small section of a program that performs a specific task - can be used repeatedly throughout the program.

23

What is a function?

A small section of a program that performs a specific task that can be used repeatedly throughout a program, but the task is usually a calculation. Functions perform the task and return a value to the main program.

24

Describe how functions return a value.

Returns a value using a RETURN statement.

25

Explain the features of a local variable.

Only exist when subroutine is executing.
Only accessible within the subroutine.
Not recognised anywhere else in program.
Form of abstraction - user of subroutine only needs to know inputs required and output of subroutine.

26

Explain why using local variables is a better practice than global variables.

Keeps subroutine self-contained. Can be used in any program and there will be no confusion over which variable names in the main program might conflict with names used in a subroutine.

27

Describe how programs should be approached in a structured manner.

Modularised approach: Uses subroutines to break down program into manageable chunks of code. Each subroutine should have a clear, well documented interface (parameters + return values).
Only uses the constructs of sequence, selection, iteration and recursion.

28

Explain the advantages of programming in a structured approach.

All advantages of subroutines.
Use of just 3 or 4 programming structures makes a program relatively easy to understand, debug and maintain.

29

Describe the term validation.

Validation is an automatic computer check to ensure that the data entered is sensible and reasonable. It does not check the accuracy of data.

30

Describe the features of a low-level language.

Limited number of programming constructs - selection and iteration being performed using 'compare and branch' instructions.
Harder to learn, time-consuming to code and more difficult to debug.

31

Describe the features of a low-level language.

Limited number of programming constructs - selection and iteration being performed using 'compare and branch' instructions.
Harder to learn, time-consuming to code and more difficult to debug.

32

Give examples of low-level language.

Machine code and assembly language (the only ones you need to know).

33

Describe differences between low-level and high-level language.

Machine code: executable binary code produced by compiler, interpreter or assembler.
Assembly language: translated using assembler, one statement translates into one machine code instruction.
High-level: independent of hardware (portable).
Translated using a compiler or interpreter.
One statement translates into many machine code instructions.
Ll instructions processed speedily than Hl languages, but more difficult for people to read + write.

34

Describe the features of a high-level language.

Selection + iteration constructs e.g. if, for and while.
Boolean operators e.g. AND, OR and NOT which enable complex conditional statements to be written.
Identifiers using unlimited number of alphabetic + numeric characters and some special characters means that variable names can be made meaningful.
Data structures e.g. arrays, as well as user-defined data types e.g. records.

35

Give examples of high-level language.

Python, Visual Basic, Java, C++

36

Describe what machine level language is.

Low-level code that represents how computer hardware and CPUs understand instructions. Represented by binary numbers.

37

Describe what assembly level language is.

Often used in embedded systems.
Gives programmer complete control over the systems components so can be used to control and manipulate specific hardware components.
Very efficient code can be written for a particular type of processor, so will occupy less memory + execute faster than a compiled high-level language.

38

Describe the differences between machine and assembly language.

Machine code is executed by the processor, and consists of only 1s and 0s. Each type of processor has its own machine code instruction set, and all programmes have to be translated into machine code before being executed.

39

Explain why code written in high level language must be translated into machine code.

Because a computer's CPU only understands (executes) series of binary numbers, and machine code is binary code.

40

Explain what assemblers are.

An assembler translates assembly language into machine code.

41

Explain what interpreters are.

Translates code into machine code, instruction by instruction - the CPU executes each instruction before the interpreter moves on to translate the next instruction.

42

Explain what compilers are.

Translates the whole program into machine code before the program is run.

43

Explain the main differences between different types of translators.

- Interpreters translate + execute a line at a time, compilers translate the whole program.
- Interpreters take more time to execute, compilers execute faster as already in machine code.
- Customers must have interpreter installed on their computer + can see source code. Don't need compiler installed to run the software.
- Customer could copy source code (interpreter), can't see actual source code when program is distributed.
- Used for program development + when program must be able on multiple hardware platforms. (Compilers) used for software that will be run frequently or copyright software sold to third party.