CS

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/57

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.

58 Terms

1
New cards

Algorithm

An algorithm is a set of instructions for solving a problem or completing a task

2
New cards

Abstraction

Abstraction involves removing unnecessary detail from a problem so that you can focus on the essential components

3
New cards

What are models used for

  •  We often build models that are simplified versions of the real world  and will remove unnecessary details

4
New cards

Decomposition

  • This involves breaking down a large problem into smaller subproblems Then the sub-problems can be broken down further until each small task is manageable

5
New cards

Advantages of decomposition

  1. The problem becomes easier to solve

  2. Some subprograms could be reusable, therefore saving development time

  3. Reduces the amount of code needed

  4. Easier to maintain and have fewer bugs

6
New cards

Arithmetic operators: +, -, /, *, **, %, //

7
New cards

How do you check answers for equations in python

x= (4 + 3)*6

print(x)

8
New cards

Variable

A location in memory in which you can temporarily store a value such as a string
or number

9
New cards

Variable names

When you assign names to variables, like mark1, and mark 2

10
New cards

what is total=total+mark 3

Add the value in the location called mark3, to the value in the location called total

11
New cards

What are the 2 main tools to help write down procedure/steps?

Flowcharts

Pseudocode

12
New cards

Flowchart symbols, pallelogram, rectangle, diamond, arrow, oval, rectangle with lines

13
New cards

When are subprograms used?

Subprograms are used when you wish to call another procedure or function

14
New cards

Sequence, how are they showed in flowcharts

A sequence is a series of steps which are completed one after the other. In a flowchart they are shown as process, input or output symbols shown one after the other.

15
New cards

Selection, how are they showed in flowcharts

Selection is the ability to choose different paths through a program. In flowcharts, decision symbols are used for selection.

16
New cards

What statement is a kind of selection?

An if statement is a kind of selection, the next statement depends on weather the condition is true or false

17
New cards

Repetition / looping/ iteration

Iteration means repeating a part of a program. In flowcharts, iteration is shown by using arrows that repeat a section of the flowchart. A decision will control whether more iterations are required

18
New cards

What are the 2 types of iteration?

  1. For loop

  2. While loop

19
New cards

What is a for loop and what kind of repetition is it

Repeat the loop for a specific number of times 

  It’s a count controlled repetition

for i in range(5):

       Print (“hello”)

20
New cards

What is a while loop and what kind of repetition is it

Repeats a set of instructions as long as a certain condition is true. You don’t have to know how many times it will repeat — it keeps going until the condition becomes false. It checks the condition before each repetition. It’s a condition controlled repetition

  • The loop keeps running as long as condition is true– e.g.
    while score < 10:

  • Keeps on running until the score reaches ten

21
New cards

What happens during iteration over a data structure?

  • This loop goes through each item in a collection like list or string* – e.g.
    for item in list:

  • It stops once it’s done printing, so when there is no more things in the list

22
New cards

What are strings

String is a sequence of characters, like letters, numbers, and symbols that are always enclosed in quotation marks. 

Eg. “Hello” “12345”

23
New cards

List 5 data types with definitions

24
New cards

List boolean operators used for comparison, greater than, equal to, greater than or equal to, less than, less than or equal to, equal to, not equal to, exponent

greater than >

greater than or equal to >=

less than <

less than or equal to <=

equal to ==

≠not equal to !=

25
New cards

Pseudocode and it’s benefits

  • Informal and rough version of real python code (not real)

  • Helps people focus on logic of the algorithm instead of the exact syntax coding language

26
New cards

How to assign a variable

Name it an use an = sign

cost = adult 2 + child 3

27
New cards

Write a statement of pseudocode to change the value stored in total to include VAT (at 20%)

  • total = total * 0.2 + total
    OR

  • total = total * 1.2

28
New cards

What is input and where is it saved

  • Most programs ask the user to type something in, like their name or age. 

  • The program then saves that input in a variable (a named storage space).

29
New cards

Display a prompt “Press Enter to continue”. When the user presses Enter, continue to the next statement.

input("Press Enter to continue")

30
New cards

Write pseudocode for a program which asks the user to enter the cost of two items, adds the two costs and if the cost is greater than £10.00, displays a message “Sorry, too much”.  Otherwise it displays  the change due from £10.00

item1 = input("Please enter price of first item:")

item2 = input("Please enter price of second item:")

total ← item1 + item2

if total > 10:

print("Sorry, too much")

else:

change = 10 – item1 - item2

print("Change from £10.00 is £", change)

31
New cards

Arrays and where does it start

Arrays are a data structure that stores many items under one identifier/name.

Each item in the array has a position number called an index (starting at 0).

32
New cards

What is iteration over an array

Iteration over an array means going through each item one by one

33
New cards

What is a 2D array like and how do you iterate through it?

  • A 2D array is basically like a table 

  • To iterate through a 2D array, you must use nested for loops (a for loop inside another for loop)

34
New cards

Which number does CS always start with

0

35
New cards

Explain the code:

num = int(input("Start number: "))

for i in range(num):

    num = num + 1

print(num)

  • The number starts at 5

  • Repeats 5 times (0-4) 

  • i is the amount of times it repeats 

  • Each time the loop runs, the number increases by 1

  • Print end result 

36
New cards

How do we determine if an algorithm is fit for purpose?

We measure the efficiency

37
New cards

How is efficiency measured by?

  • Comparisons – How many items it compares

  • Loop passes – How many times it loops

Memory used – How much space it takes up

38
New cards

How many input(s) are there in trace tables

1

39
New cards

How does this code work?

num = int(input("Start number: "))

for i in range(num):

    num = num + i

print(num)

Add i to current number to make it a new number

40
New cards

What is the algorithm, number of passes through a loop, and use of memory in this code?

num = int(input("Start number: "))

for i in range(num):

    num = num + i

print(num)

Algorithm= Version 1

Number of passes through a loop= 5

Use of memory= i, num

41
New cards

What is the algorithm, number of passes through a loop, and use of memory in this code?

num = int(input("Start number: "))

result = ((num + 1) * num) / 2

print(result)

Algorithm= Version 2

Number of passes through a loop= 1 (no loops)

Use of memory: num, result

42
New cards

Why is algorithm 2 more efficient

  • Far more efficient in loops/processing; same use of memory

43
New cards

Syntax error

program code doesn’t conform to the rules/grammar of the language and won’t run

44
New cards

Logic error

the program runs but doesn’t do what the programmer intended

45
New cards

Runtime error

an error when the program is running – e.g. out of bounds or divide by zero

46
New cards

What does a trcae table do?

It records the values of variables as a program is ‘run’ by a human

47
New cards

What are the 2 different types of search algorithms?

  1. Linear search

  2. Binary search

48
New cards

Linear search

searches each item in the list one by one until it’s found the wanted one

49
New cards

Binary search

 searches list by dividing it by 2, then going on to the first one when there’s only 2 left 

50
New cards

What are the 2 different types of sorts?

  1. Bubble sort

  2. Binary sort

51
New cards

Bubble sort

Compare two numbers next to each other, and swap them if they’re in the wrong order. Do this again and again until the whole list is sorted in numerical order or alphabetical order 

knowt flashcard image

52
New cards

Merge sort

Split the list into smaller pieces (halving) until each piece has 1 item. Then merge those pieces together in the correct order.

53
New cards

What are the 3 different types of logic gates?

And, or, not

knowt flashcard image

54
New cards

What does an AND logic gate do?

Both inputs must be true for the output to be true, both must be 1.

55
New cards

What does a NOT logic gate do?

At least one input must be true for output to be true. (1)

56
New cards

What does an OR logic gate do?

The output would be opposite the input

57
New cards

What does a truth table show?

It shows all the possible combinations of inputs and outputs they create

58
New cards

Python symbols