7.3 Programming 1 Flashcards

1
Q

What is an algorithm?

A

A set of instructions the computer follows in sequence.

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

What is a sequence?

A

The order the program runs in.

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

What is a variable?

A

A location in memory that stores one piece of data. It can change as the program runs.

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

What is iteration?

A

When a block of code repeats/loops.

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

What are the two iteration loops used in Python?

A

A for loop is count controlled, whereas a while loop is condition controlled.

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

Why is iteration used in a program?

A

To make the program more efficient, e.g. less lines of code so the program runs faster.

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

What does selection mean?

A

The user has a choice and the program has different routes to follow based on the choice.

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

What are the key terms you would expect to see when reading a selection statement?

A

If/elif/else.

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

What is the purpose of indentation?

A

The code belongs to the specific selection statement.

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

Write a print statement.

A

print(‘A print statement’)

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

Write an input statement for the user entering their name.

A

name = input(‘Enter your name: ’)

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

How do the four types of malware get into the computer system?

A

Virus, worm, trojan and ransomware.

Virus - attaches; Worm - duplicates; Trojan - pretends; Ransomware - locks.

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

What is a list?

A

A location in memory that stores multiple elements under one name.

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

What is the difference between a variable and a list?

A

A variable can only store one element whereas a list stores multiple elements.

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

How is a list defined in Python?

A

listName = [] (square brackets).

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

What are the numbers in the binary number line?

A

128, 64, 32, 16, 8, 4, 2, 1.

17
Q

When converted to denary, the binary number 1001 is:

A

8 + 1 = 9.

18
Q

When converted to binary, the denary number 29 is:

A

29 - 16 = 13; 13 - 8 = 5; 5 - 4 = 1; 11101.

19
Q

Describe how an insertion sort is carried out.

A

An insertion sort is where the numbers are inserted into the correct position. It is the quickest kind of sorting.

20
Q

Describe how a merge sort is carried out.

A

A merge sort is where we divide and conquer - octo (8) - quads (4) - pairs (2) then sort pairs (2) - quads (4) - octo (8).

21
Q

Describe how a bubble sort is carried out.

A

In the bubble sort, you sort the pairs: 1st pass - start at 1st item; 2nd pass - start at 2nd item; 3rd pass - start at 1st item; 4th pass - start at 2nd item etc.

22
Q

Describe how a linear search is carried out.

A

A linear search is where each item in the list is checked until the correct item is found. This can be a slow process if the list is long.

23
Q

Describe how a binary search is carried out.

A

A binary search is where the list is divided in 2 - is the item you are looking for in the top half or bottom half - get rid of the half of the list it is not in, and repeat the process until you find the item you are looking for.