8.2 Programming Flashcards
What is an algorithm?
A set of instructions the computer follows in sequence?
What is a sequence?
The order the program runs in.
What is a variable?
A location in memory that stores one piece of data. It can change as the program runs.
What is iteration?
When a block of code repeats/loops?
What are the two iteration loops used in Python
A for loop is count controlled, whereas a while loop is condition controlled.
Why is iteration used in a program?
To make the program more efficient, e.g. less lines of code so the program runs faster.
What does selection mean?
The user has a choice and the program has different routes to follow based on the choice
What are the key terms you would expect to see when reading a selection statement?
If/elif/else
What is the purpose of indentation
The code belongs to the specific selection statement
Write a print statement
print(‘A print statement’)
Write an input statement for to user entering their name
name = input(‘Enter your name: ‘)
How do the four types of malware get into the computer system:
Virus, worm, trojan and ransomware?
Virus - attaches
Worm - duplicates
Trojan - pretends
Ransomware - locks
What is a list?
A location in memory that stores multiple elements under one name
What is the difference between a variable and a list?
A variable can only store one element whereas a list stores multiple elements.
How is a list defined in Python?
listName = [] (square brackets)