Programming Contrstucts Flashcards

(29 cards)

1
Q

Define a Variable

A

A named location in computer memory used to hold data when a program is running. The value of the variable can change while the program is running

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

Define a Constant

A

A named location in computer memory used to hold data when a program is running. The value of the variable cant change while the program is running and remains constant

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

Define a Boolean operator

A

An operator that allows conditions to be combined then evaluated , the outcome is a Boolean variable

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

Define a Arithmetic Operator

A

Enables arithmetic operations to be carried out using variable

+,-,*

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

Define an Input Statement

A

A statement used to capture data which is to be used in the program

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

Define an Output Statement

A

A statement used to output data and information from the program

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

Define an Assignment Statement

A

A statement that assigns a value to a variable, constant or other data structure

A= b+c

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

What are the three program control structures

A

Sequence
Selection
Iteration

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

Define Sequence

A

denotes the order in which the instructions are carried out by the computer

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

Describe Selection

A

In selection a condition is used to decide which piece of code should be executed.

This is acheived through the use of IF statements and BOOLEAN operateors

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

Describe Iteration

A

another word for reptation

Repetitions is used when a section of code is to be carried out more than once

This can be acheived through loops

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

What is an Array?

A

An array is a data structure that holds a set of data items of the same data type

The arrays assigned a name, a size and a data type by the program

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

Define a Bubble Sort

A

Bubble sort is a simple sort that compares adjacent elements, which are compared and swapped if in the wrong order

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

Define an Insertion Sort

A

builds a sorted sub list one item at a time, the sub list become the new sorted list

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

How does bubble sort work?

A

Compare the first and second items, swap if needed. Then compare the second and third,
and so on. Repeat the whole process until no swaps are needed.

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

How does insertion sort work?

A

Start with the second item, compare it to the first, and insert it in the correct place. Then take
the third, compare to the sorted part, and insert again — like sorting playing cards in your
hand

17
Q

Define Linear Search

A

A simple search that compares every data item in a list to the target value

18
Q

Define a Binary Search

A

Binary Search is a fast way to find a value in a sorted list by repeatedly dividing the list in
half.

19
Q

How does a linear search work

A

Go through each item in the list, one at a time, and check if it matches the target.

20
Q

How does a Binary Search Work?

A

Start in the middle of the list. If the middle value is the target, you’re done. If the target is
smaller, search the left half. If it’s larger, search the right half. Repeat this process.

21
Q

What is a string?

A

data containing text, letters or a mixtures of letter and numbers

22
Q

What are the 4 string manipulation functions?

A

Splitting
concatenating
character searching
substring searching

23
Q

Explain the string manipulation function concatenating

A

appending strings together relevant function of symbol

example:

string1 + “” + string 2

24
Q

Explain the string manipulation function Substring Searching

A

using a start position and a length, it returns a substring

example:

string2 = award-winning-performance
string2.substring(6:13)

result= winning

25
Key facts about arrays
The computer reserves a lot of set memory location, 1 for each element in the array, they are next to each other/contiguous The first index is numbered 0 as arrays are 0 indexed Elements can be assigned values myNumbers[0] = 47 Python uses lists and tuples instead of arrays, tuples can hold mixed data types To access every element in the array a loop can be used
26
What would you write to get a lowercase string?
string is called string1 string1.lower()
27
What would you write to get an uppercase string?
string is called string1 string1.upper()
28
What would you write to return the length of a string.
string is called string1 len(string1)
29
Key facts about functions/methods
Functions are given a name Data in the form of parameters can be passed to functions Functions can return data Give programmers the opportunity to structure code so that it is more efficient Functions can be re-used within a program