9.3 Programming 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 to 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:
Virus, worm, trojan and ransomware?

A

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

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

When converted to denary, the binary number 1001 is:

A

8 + 1 = 9

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

When converted to binary the denary number 29 is:

A

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

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

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

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

Describe how 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….

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

Describe how an 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.

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

24
Q

What is computational thinking?

A

Computational thinking is about breaking a big problem into smaller manageable problems: Abstraction - selecting the relevant information, Decomposition - breaking it down into steps, Algorithmic thinking - writing short programs for each step.

25
Q

What is a structure diagram?

A

A structure diagram is a decomposition tool that shows visually the different steps in solving the problem.

26
Q

When have I come across computational thinking before?

A

Maths - BIDMAS: Brackets, Indices , Division, Multiplication, Addition and Subtraction.

27
Q

What is Python?

A

Python is a text-based programming language, which is close to the English language and is translated in order for a computer to understand.

28
Q

What are de Facto standards in programming?

A

De Facto standards are the expected standard of presentation when writing programs, including title-author-date, this program is designed to… and #comments throughout code.

29
Q

What is an array?

A

An array is another word for a list. An array/list store multiple pieces of data in one location.

30
Q

What is a variable?

A

A variable stores one piece of data, and can change at the program runs?

31
Q

How is an array shown in Python?

A

With a name for the array and square brackets, e.g. studentList = [ ]

32
Q

What is iteration?

A

When a block code is repeated either until a condition is met or for a certain number of times.

33
Q

What key terms would you expect to see when reading iterative statements?

A

For loop or while loop

34
Q

What is the purpose of indentation

A

Repeat the block of code with the iterative statement

35
Q

What is computational thinking?

A

Computational thinking is where you take a big problem and break it down into steps and work through logically.

36
Q

Write a print statement

A

print(‘A print statement’)

37
Q

Write an input statement for to user entering their name

A

name = input(‘Enter your name: ‘)

38
Q

What does selection mean?

A

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

39
Q

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

A

If/elif/else

40
Q

What is the purpose of indentation?

A

The code belongs to the specific selection statement

41
Q

What are the numbers in the binary number line?

A

128 64 32 16 8 4 2 1

42
Q

When converted to denary, the binary number 1001 is:

A

8 + 1 = 9

43
Q

When converted to binary the denary number 29 is:

A

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

44
Q

What are the numbers in the hexadecimal line

A

0 1 2 3 4 5 6 7 8 9 A B C D E F
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

45
Q

What is the hexadecimal A4 in binary

A

8 4 2 1 8 4 2 1
1 0 1 0 0 1 0 0

46
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.

47
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)

48
Q

Describe how 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….

49
Q

Describe how an 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.

50
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.

51
Q

What is a function?

A

A function changes as the program runs, e.g. calculation (returns a value)

52
Q

What is a procedure?

A

A procedure does not change as the program runs, e.g. process (can have a value passed to it)

53
Q

What is the difference between defining and calling a function

A

Defining creates the function or procedure which is then called in the main program

54
Q

How do you read from a file in Python?

A

“r” - Read - will read a file, e.g.

f = open(“demofile.txt”, “r”)
print(f.readline())
f.close()

55
Q

How do you write to a file in Python?

A

“w” - Write - will create a file if the specified file does not exist, e.g.

f = open(“demofile.txt”, “w”)
print(f.readline())
f.close

56
Q

How do you alter/add to a file in Python?

A

“a” - Append - will create a file if the specified file does not exist

f = open(“demofile2.txt”, “a”)
f.write(“Now the file has more content!”)
f.close()