2.1 Introduction to Python 24/25 Flashcards

Year 10 Autumn 2

1
Q

What is a syntax error?

A

When the rules of grammar of the programming language have been broken.

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

What is a logic error?

A

When a program is able to run but does something unexpected.

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

Which part of the IDE identifies errors?

A

The Error Diagnostic will locate and identify the syntax error in the code.

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

Which type of errors does the Error Diagnostic identify?

A

The Error Diagnostic locates syntax errors, e.g. errors in the structure of the code.

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

Describe how bubble sort is carried out.

A

After the first pass, the largest item is in the correct place. After the second pass, the largest two items are in the correct place etc. etc. until after the final pass, only two items need to be sorted.

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

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

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

What is a variable?

A

A location in memory that stores one item. A variable can change as the program runs.

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

What is a constant?

A

A location in memory that stores one item. A constant cannot change as the program runs.

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

What is an input statement?

A

An input statement allows the user to interact with the program.

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

How would an input statement appear in an exam question?

A

The program asks the user to… - variableName = input(“Statement”)

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

What is an output statement?

A

An output statement will display the processed information.

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

How would an output statement appear in an exam question?

A

The program outputs the … - print (“output”) or print(variableName)

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

What are the main data types?

A

String, integer, float, real, character, Boolean.

17
Q

What is a string?

A

A data type that includes letters, numbers, special characters etc, e.g “words” (look for the speech marks).

18
Q

What is the difference between an integer and a real/float data type?

A

An integer is a whole number whereas a float/real is a decimal number.

19
Q

What is the difference between MOD and DIV?

A

DIV // Integer division finds the quotient (e.g. how many times the divisive goes into the value) and MOD % finds the remainder.

20
Q

What is exponentiation?

A

^ or ** means to the power of.

21
Q

What is the purpose of the random number generator?

A

A random number generator brings the random element into programs, for example if a user plays a game against a computer.

22
Q

How would this appear in an exam question?

A

The program outputs a random number… - randomNum = random.randint(1,10)

23
Q

What are the boolean operators?

A

True and False.

24
Q

What are the boolean logic gates?

A

AND (both), OR (either), NOT (opposite).

25
Q

What is the purpose of len(string)?

A

Returns the length of a string.

26
Q

What is the purpose of concatenating a string?

A

Returns the variables joined together.

27
Q

What is the purpose of slicing a string?

A

Returns a range of characters. Specify the start index and the end index, separated by a colon, to return a part of the string.