Programming Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What does execution mean?

A

The process by which a computer carries out the instructions of a computer.

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

What do algorithm consist of?

A

A sequence of unambiguous,step-by-step instructions.

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

What is a program an example of?

A

An algorithm that has been converted into program code so that it can be executed by a computer.

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

What should a well-written algorithm be?

A

Free of logical errors and easy to code in any high-level language.

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

Can you give 4 differences between an algorithm and program?

A

Command words in pseudo-code are written in capital letters,in python they’re written in lower case.
SET…TO(pseudo-code) is replaced in python by an =.
RECEIVE..FROM in pseudo-code is replaced in python by an’input’.
SEND..TO DISPLAY in pseudo-code command in python translates to’print’

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

What are the main similarities between algorithms and programs?

A

Both use descriptive variable names.
Indentation features in both.
The three programming constructs-sequence,selection and iteration(basic building blocks of both)

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

What are the three programming constructs?

A

Sequence,selection,and iteration

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

What is a syntax error?

A

An error that occurs when a rule of the programming language is broken.

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

What will happen if a piece of code isn’t right,for a computer?

A

It won’t be able to execute it and will flag a syntax error.

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

Why do algorithms use variables?

A

(named memory locations)to store values.

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

Why are variables important for computers?

A

They have a variety of uses ,for example controlling the number of times a loop is executed.
When algorithms are converted into programs the computer needs to be told what type of data is stored in each variable.

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

What are data types?

A

specifies what kind of data it can hold.

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

What are common data types?

A

Integer,real,Boolean and character

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

What does the data type of a value determine?

A

The operations that can be performed upon it.

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

What is an integer?

A

Used to store whole numbers without a fractional part.

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

What is real and what is it sometimes referred to?

A

Used to store numbers with a fractional part.Real numbers are sometimes referred to as floats.

17
Q

What is Boolean?

A

Only has two possible values;True and False

18
Q

What is a character?

A

Used to store a single character or symbol.

19
Q

In pseudo-code what don’t you have to specify?

A

The data types of variables.

20
Q

Why do data types become much more important once you start programming in a high-level language?

A

The data type of a variable determines the operations that can be performed on it.

21
Q

How can you put an initial value into a variable?

A

By..
initialising it when the program is run
reading a value from a keyboard or other device

22
Q

What is initalisation?

A

the process of assigning an initial value to a variable.

23
Q

What is a assignment statement?

A

the SET..TO command is used to initialise variables in pseudo-code.

24
Q

Once a variable has been initialised,what happens?

A

An assignment statement is used to change its value

25
Q

Why should variables always be initalised to a starting value?

A

Some programming languages won’t execute if the programmer fails to do this;others will do so but may produce some unexpected results.

26
Q

What is a type coercion?

A

when the data type of a variable gets changed during program execution.

27
Q

What’s a command sequence?

A

A set of instructions that the computer executes one another in order.

28
Q

What are command sequences usually combined with?

A

Loops and selection statements.

29
Q

What is the selection construct used to create?

A

A branch in a program.The computer selects which branch to follow based on the outcome of a condition.

30
Q

What is a definite loop used for?

A

When you know in advance how often the instructions in the body of the loop are to be repeated.

31
Q

What is a indefinite loop used for?

A

When the number of times a loop will need to be repeated is not known in advance.

32
Q

why use constants?

A
  • Readability-a named constant makes it clear
  • Ability to update-if you need to update the constant value,all you need to do is update the initial value once.
  • Compiler optimisation-depending on the compiler,use of named constants can lead to optismisation,either improving performance or reducing memory space.
33
Q

what are constants?

A

identifiers associated with values that remain fixed during the program’s execution.

34
Q

How can a readability of a code be improved?

A
  • Use descriptive names for variables
  • Add blank lines between different blocks to make them stand out
  • Add comments that explain what each part of the code does.
35
Q

How can descriptive names be used to improve a programs readability?

A

Using descriptive identifiers for variables,constants and subprograms help to make their purpose clear.

36
Q

how can indentation be used to improve a programs readability?

A

makes it easier to see where each block of code starts and finishes.If the indentation is wrong then it can lead to the program not running or producing the expected outcomes.

37
Q

how can white space be used to improve a programs readability?

A

adding blank lines between different blocks of code makes them stand out.

38
Q

How do write a comment in python and java?

A

for python
Java:single line comment//
multi-line comment with /and end with /