Programming Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is an algorithm?

A

An algorithm is a sequence of instructions that can be followed to solve a problem, and that always terminates.

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

How is pseudocode used?

A

Pseudocode is used to write instructions using statements that are somewhere between English and a programming language.
There are guidelines for writing pseudocode, but no strict rules.
Pseudocode is an aid to work out the steps needed to solve a problem before beginning to code.

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

How are flowcharts used?

A

A flowchart is a diagram used to illustrate the steps of an algorithm.
Flowcharts are made up of symbols, each containing a single step of the algorithm.
The shape of the symbol represents the type of process that the symbol contains.
Arrows are used to show the flow of execution, meaning that flowcharts can represent all the core concepts of programming, namely sequence, selection, and iteration.

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

What is a variable?

A

A named piece of memory that holds a value. The value it holds can, and often does, change during the running of a program.

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

What is a constant?

A

A named piece of memory where the value cannot be changed while a program runs.

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

Why are constants useful?

A

Constants are useful because they are declared and assigned once, but can be referred to over and over again throughout the program. This means that if the programmer needs to change the value throughout the program code, they only need to make one change. This can help make a program easier to maintain.

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

What naming conventions do constants follow?

A

Constants follow the same naming conventions as variables, except that they are often written in uppercase. Some programming languages, such as Python, do not support constants.

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

What is a data type?

A

How data is stored depends on what the data is. A data type is defined by the values it can take or the operations which can be performed on it.

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

How do programmers decide which data type to use?

A

In some situations, it might be possible to store one piece of data using various different data types. In this case, the programmer must decide which option is the best suited to solving a particular problem or which is the most memory-efficient.
For example, if a programmer needs to store a user’s age in years, they could use a string or an integer. In this situation, using an integer would be the best option, because a person’s age is only ever going to contain numerical digits.

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

What is an integer?

A

A whole number, which can be positive, negative, or zero.

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

What is a real/float?

A

A number which can have a decimal part. The number can be positive, negative, or zero.

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

What is a Boolean?

A

A value that is either True or False.

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

What is a character?

A

A single number, letter, or symbol, enclosed in quotation marks, e.g. ‘a’, ‘9’, ‘@’, ‘!’.

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

What is a string?

A

A list of characters enclosed in quotation marks, e.g. ‘Hello’, ‘ABC123!’.

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

What is a date/time?

A

A way of storing a point in time. Many different formats are used.

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

What is a pointer/reference?

A

A way of storing memory addresses.

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

What is a record?

A

A collection of fields, each of which could have a different data type. You can think of a record as a row from a table.

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

What is an array?

A

A finite, indexed set of related elements each of which
has the same data type.

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

What is a list (Python)?

A

A list is similar to an array, but more flexible. It can be altered while the program is running, doesn’t have a fixed length, and elements can be of different data types.

20
Q

What are assignment statements written with in pseudocode?

A

Assignment statements can be written using <– or =.
E.g. Name <– “David”

21
Q

Which symbol is used for addition in Python?

A

+

22
Q

Which symbol is used for subtraction in Python?

A

-

23
Q

Which symbol is used for multiplication in Python?

A

*

24
Q

Which symbol is used for division in Python?

A

/

25
Q

What symbol is used for exponentials in Python?

A

**
e.g. 3**2 = 9

26
Q

What is integer division/DIV?

A

It returns the integer part of a division.
E.g. 5 DIV 2 = 2

27
Q

Which symbol is used to represent integer division in Python?

A

//
E.g. 5//2 = 2

28
Q

What is the modulo function/MOD?

A

It returns the remainder of a division.
E.g. 5 MOD 2 = 1

29
Q

Which symbol is used to represent the modulo function in Python?

A

%
E.g. 5%2 = 1

30
Q

What are user-defined data types and why are they used?

A

User-defined data types are derived from existing data types to create a customised data structure. Creating and using user-defined data types allows a programmer to ensure that a solution is as memory efficient as possible.
For example, a shop might use a user-defined data type called Customer to store information about their customers. The user-defined data type might have attributes like Forename, Surname and EmailAddress.

31
Q

What is variable/constant declaration?

A

Creating a variable or constant for the first time, giving it a name
and sometimes a data type. This allocates a portion of
the computer’s memory to the variable/constant.
(In Python, variables and constants don’t need to be declared before assignment)

32
Q

What is assignment?

A

Assigning a value to a variable or a constant.

33
Q

What is iteration?

A

Repeating an instruction, this could be definite or
indefinite.

34
Q

What is selection?

A

When different sections of code are executed based on whether a condition is met or not.

35
Q

What is a subroutine?

A

A named block of code containing a set of instructions.
Subroutines can be called from anywhere within a program and are typically designed to carry out a frequently used action.

36
Q

Which Python function can be used to find the length of a string?

A

len()

37
Q

How do you find the character at a specific position in a string?

A

In Python this works similarly to selecting an element from a list based on its index.
The syntax is like this: String[index]
E.g.
greeting = “Hello”
print(greeting[4]) prints o
Remember indexing starts at 0.

38
Q

How do you select a substring from a string?

A

Similar to getting a singular character, but you have to specify two values.
The syntax is like this: String[start index, end index + 1]
E.g.
greeting = “Hello there”
print(greeting[6,10]) prints “there”
Remember indexing starts at 0.

39
Q

What is concatenation?

A

Joining multiple string together.

40
Q

How do you concatenate strings in Python?

A

You can concatenate strings either using commas or plus signs.
E.g.
print(“Hello” , “there”)
print(“Hello” + “ there”)
Both print “Hello there”
Commas automatically add a space between the strings that are being concatenated.

41
Q

How do you concatenate a string and an integer or float in Python?

A

If using a plus sign, you have to convert the integer/float into a string.
price = 20
E.g. print(“This costs £” +str(price))
Prints “This costs £20”
Commas don’t require you to change the datatype, but do add a space between each item that you’re concatenating together.

42
Q

How do you find the ASCII code of a character in Python?

A

Using the built-in ord() function.
e.g. print(ord(“L”)) would print 76.

43
Q

How do you convert an ASCII code to its character value in Python?

A

Using the built-in chr() function.
e.g. print(chr(65)) prints “A”

44
Q

How do you convert a string to an integer in Python?

A

Using the built-in int() function.
e.g. int(“10”) converts the string “10” to the integer 10.

45
Q

How do you convert a string to a float in Python?

A

Using the built-in float() function.
e.g. float(“10.3”) converts the string “10.3” to the float 10.3.

46
Q

How do you convert an integer or a float to a string in Python?

A

Using the built-in str() function.
e.g. str(10) converts the integer 10 into the string “10”.

47
Q

How do you convert a date/time into a string in Python?

A

Using the built-in str() function.