paper 2

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/63

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

64 Terms

1
New cards

Flowchart

A diagram that shows the step by step instructions of an algorithm using standard symbols

2
New cards

Pseudocode

A method of writing up a set of instructions for a computer s program using plain English

3
New cards

What is the most common input device?

The keyboard

4
New cards

What command in Python allows user input?

Input

5
New cards

Example of an input statement

Input(“prompt”

6
New cards

Input(“prompt”)

What is the prompt?

A message displayed on a users screen before they input their answer

7
New cards

What is the output function in Python?

Print

8
New cards

Example of a print statement

Print(“ hello, world!”)

9
New cards

Output data must be a _____ before we can print it

String

10
New cards

If we want to print data which is not a string, then we must…

Cast it to a string

11
New cards

What are the data types?

  • Boolean (true/false)

  • Integers (whole numbers - 1,3,2828)

  • Float (decimal numbers- 3.6 7.6288)

  • String (text- “hello world”)

12
New cards

Data types determine

How data is stored and what you can do with it

13
New cards

Casting

The process of converting a value from one data type to another, such as turning a string into an integer or vice versa

14
New cards

All input’s must come out as a string and must be

Converted to other data types

15
New cards

Casting to a string can be done using what function?

The str function

Eg; str(3) gives “3”

16
New cards

Int(3.4) would result as

The number 3

17
New cards

Type coercion allows us to…

Operate on data of different types

18
New cards

When adding two numbers of different data types, type coercion…

Allows one of the types to be automatically cast so that the operation can be completed

19
New cards

When working with a float and an integer, the final result will be a

Float

20
New cards

When working with a string and an integer, the result will be a

String

21
New cards

What is a variable?

A named memory location that holds data that can change while a program is running

22
New cards

What is a constant?

A named memory location where the value remains unchanged throughout a programs execution

23
New cards

The value of a variable can ….

Change whilst a program is running

24
New cards

To use a variable, we give it an _____ and a _____

Identifier, value

25
New cards

Operators are

Symbols that represent a specific function within a program

26
New cards

Relational operators

Operators which compare two values and produce a true or a false result

27
New cards

Boolean operators

Operators which perform logical operations and always results in a true or false value

28
New cards

What does MOD do?

Gives the reminder of a division. Eg:

5 MOD 2=1

29
New cards

What does DIV do?

Returns the quotient (whole part) of the division, Eg:

5 DIV 2 = 2

30
New cards

3//2

1

31
New cards

3/2

1.5

32
New cards

What is the assignment operator

=

33
New cards

Selection

A programming construct where a program makes a decision to run a specific block of code based on a condition, which can either be true or false.

34
New cards

What are the methods of selection

Else, if, Elif statements

35
New cards

If statement

Conditions can be tested using this statement, for example:

If( x > 50 ):

36
New cards

Else statements

We can add an else statement after an IMF statement, for example:

Else:

This will only execute the following block of code if the condition is false.

37
New cards

Elif statements

These statements can be added between if and else blocks.

  • they will execute the condition before it was false, and the condition following it is true.

38
New cards

Example of using an if statement

IF condition 1:

action 1()

39
New cards

Example of using an elf statement

Elif condition2:

Action2()

40
New cards

Example of using the else statement

Else:

action3()

41
New cards

Iteration

The process of repeating a set of instructions or code in a program, also known as a “loop

42
New cards

Iteration techniques

  • while loop

  • Repeat until

  • For

  • Do while

43
New cards

A flow diagram for iteration uses a

Diamond shape

44
New cards

What is definite iteration?

  • a block of code will repeat a known number of times

45
New cards

What is indefinite iteration?

  • a block of code will repeat whilst a specified condition is true

46
New cards

What would an example of definite iteration be?

A for loop will execute an indented block for each value in a list of values

47
New cards

What would be an example of indefinite iteration?

A while loop will continue to execute an indented block of code while a certain condition is true

48
New cards

Example of a for loop

For i in range(0,10):

action1()

action2()

49
New cards

Example of a while loop

While condition:

action 1()

action 2()

50
New cards

Listing

A data structure which holds a finite, ordered collection of items under a single identifier

51
New cards

What’s the main difference between listing and arrays?

Lists can hold data values with differing data types whereas arrays tend to elements of the same data type

52
New cards

list example

my_list = [1, "apple", True# works fine

  • it holds multiple data types

53
New cards

Array example

my_array = array.array('i', [1, 2, 3])

  • ‘i’ indicates integer

54
New cards

What do we use to add to an array?

Append

55
New cards

Example code for adding to an array

Myarr.append()

56
New cards

What would list[5].append(3) do?

Add 3 to the 6th inner list

57
New cards

The [5] would be the sixth list because

0 1 2 3 4 5 is six values altogether

58
New cards

What are the uses of 2D lists/arrays?

To represent a 2D surface, for example- a chess board

59
New cards

code to access an individual list from a 2D list

List= my2Dlist[4]

60
New cards

List[5][0] would allow us…

To access an individual element, this would give us the first element [0] of the sixth list [5]

61
New cards

2D list/array

A data structure where lists are filled with other lists

62
New cards

What is abstraction?

the process of simplifying a problem by removing all unnecessary details to focus only on the essential ones

63
New cards

What is defragmentation?

the process of reorganizing data on a hard disk drive so that all the fragments of a file are stored in a single, contiguous block of space

64
New cards

Whats the point of casting?

to convert data types for operations