1/89
Study guide for computer science
What is programming?
Sequencing instructions in the correct order.
Why is the order of instructions important?
The sequence order matters, and accuracy is important.
What is Python?
A programming language that is simple to learn.
Name some applications or organisations that use Python.
NASA, Paint Shop Pro, Google Search, Civilization 4, CERN and Dropbox.
What does IDE stand for?
Integrated Development Environment.
What are the two screens in the online IDE described in the lesson?
Shell and Terminal.
What is the Shell used for?
Typing your code.
What is the Terminal used for?
Displaying your program's outputs.
What is the purpose of a Hello World program?
It displays text on the screen; it is a programming tradition.
Which Python function displays text?
print()
Which Python function accepts user input?
input()
What is a syntax error?
An error in the code's syntax that prevents it being written or understood correctly.
What does a NameError message indicate?
A name used in the code has not been defined, such as a misspelt function name.
What is debugging?
Finding and fixing errors in a program.
What is a computer bug?
An error in a program.
What is a variable?
A location in memory used to temporarily store text or numbers.
What is a variable name?
The name chosen for a variable, like the name of a box storing a value.
What characters can a Python variable name contain?
Numbers, letters and underscores.
Can a Python variable name start with a number?
No.
Can a Python reserved word be used as a variable name?
No; for example, class is a reserved word.
Why should variable names be meaningful?
They make programs easier to understand.
What is a comment used for?
To document a program and make code easier to understand.
What symbol starts a Python comment?
#
Do comments affect how a program runs?
No.
What is a Python function?
A special built-in routine that performs a specific job.
Give two examples of Python functions from the lesson.
print() and input().
What is a string?
A data type that holds alphanumeric data as text.
What is an integer?
A data type that holds whole numbers.
What is a float?
A data type that holds numbers with a decimal point.
What is a Boolean?
A data type that holds either True or False.
What data type does input() return?
A string.
What is casting?
Manually defining or changing a variable's data type.
Which function converts a value to a string?
str()
Which function converts a value to an integer?
int()
Which function converts a value to a float?
float()
What does round() do?
Rounds a number, optionally to a chosen number of decimal places.
What does round(228.374, 2) return?
228.37
What is an assignment statement?
A statement that assigns a value to a variable.
What happens if an assignment uses a variable that does not already exist?
The variable is created.
What does BIDMAS stand for?
Brackets, Indices, Division and Multiplication, Addition and Subtraction.
Why does the order of arithmetic operations matter in programming?
The order affects the calculation's result; BIDMAS applies.
Which Python operator is used for addition?
+
Which Python operator is used for subtraction?
-
Which Python operator is used for multiplication?
*
Which Python operator is used for division?
/
Which Python operator is used for floor division?
//
Which Python operator gives the remainder?
%
What is the result of 7 // 2?
3
What is the result of 7 % 3?
1
What are the three stages of a program involving input, calculation and output?
Accept input, perform a calculation, then display output.
What is selection in programming?
Using a condition to make a decision about which code runs.
What does an if statement do?
Checks a condition and runs a block of code if it is true.
What does else do in an if statement?
Runs the alternative block when the if condition is false.
What does elif mean?
Else if; it checks another condition and allows more than two options.
How many times can elif be used in a selection structure?
As many times as needed.
What does the comparison operator == mean?
Equal to.
What does the comparison operator != mean?
Not equal to.
What does the comparison operator > mean?
Greater than.
What does the comparison operator < mean?
Less than.
What does the comparison operator >= mean?
Greater than or equal to.
What does the comparison operator <= mean?
Less than or equal to.
What is indentation used for in Python?
It marks the start and end of a block of code.
Why is correct indentation important?
Incorrect indentation can stop a program running or make it give the wrong result.
What is pseudocode?
A mixture of code and English used to plan an algorithm.
Does pseudocode have real programming syntax?
No; it would not run as program code.
Why is pseudocode useful?
It helps plan algorithms without needing the exact syntax of a programming language.
What should be used in pseudocode to show code blocks?
Indentation.
Name some common pseudocode instructions.
input, print, display output, calculate, add, set, if, then, else and endif.
What is an algorithm?
A planned sequence of steps to solve a problem or complete a task.
Name the three types of programming error in the lesson.
Syntax errors, run-time errors and logic errors.
What is a while loop used for?
Repeating code while a condition is true.
What happens when a while loop's condition is false?
The loop stops and the program continues after it.
What happens when a while loop's condition is true?
The conditional code inside the loop runs.
What is a counter variable used for in a loop?
To keep track of how many times something happens.
How can a counter be increased by one in Python?
counter = counter + 1
What is a running total used for?
To keep adding values together as they are entered.
How can an if statement be used inside a while loop?
To make a decision during each repetition of the loop.
What is the random module used for?
Generating random numbers.
What Python statement imports the random module?
import random
How do you generate a random integer from 1 to 6 in Python?
random.randint(1,6)
What is a linear search?
A search that examines each item in a list one at a time, from the beginning.
Does a list need to be sorted for a linear search?
No.
What is a binary search?
A search that repeatedly halves the range of an ordered list.
Does binary search require the data to be ordered?
Yes; it is used on a sorted or ordered list.
What is the first step in a binary search?
Find the midpoint of the range.
In binary search, what happens if the target is lower than the midpoint?
Discard the upper half and search the lower half.
In binary search, what happens if the target is higher than the midpoint?
Discard the lower half and search the upper half.
Why can binary search be more efficient than linear search?
It halves the search range each time instead of checking items one by one.
Give examples of places where binary search may be used.
Searching ordered registration numbers, supermarket product details, hospital records or insurance policies.
What is the maximum number of guesses for a binary search over 1–100, according to the lesson?
7 guesses.