R354 - CTAP2 Computational Thinking, Algorithms and Programming 2

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

1/65

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.

66 Terms

1
New cards

Variable

A named location in memory. Storing a single piece of data, which can be changed during run time.

2
New cards

Create a variable named year and assign it to the value of the current year as an integer

year = 2024 OR year = int(2024)

3
New cards

What is the value of num3 when this code has executed?
num1 = 5
num2 = 10
num3 = num1*num2

50

4
New cards

What is the value of num3 when this code has executed?
num1 = 21
num2 = 7
num3 = num1/num2

3.0 (results of division are stored as floats/real)

5
New cards

When programming what do we use the * operator for?

Multiplication

6
New cards

In the example below what does the + represent?
num3 = num1+num2

Addition

7
New cards

In the example below what does the + represent?
firstName = 'Ada'
surname = 'Lovelace'
fullName = firstName + ' ' + surname

Concatenation (joining of strings)

8
New cards

When programming what do we use the / operator for?

Division

9
New cards

When programming what do we use the - operator for?

Subtraction

10
New cards

When programming what do we use the == operator for?

Equal to

11
New cards

When programming what do we use the != operator for?

Not equal to

12
New cards

When programming what do we use the > operator for?

Greater than

13
New cards

When programming what do we use the >= operator for?

Greater than or equal to

14
New cards

When programming what do we use the < operator for?

Less than

15
New cards

When programming what do we use the <= operator for?

Less than or equal to

16
New cards

What python keyword do you use to accept data from user into your program?

Input

17
New cards

Write the code to ask the user for a number and store it as a variable named guess

guess = int(input("Enter your number: "))
#It doesn't matter if you wrote something else in the brackets but the "" do!

18
New cards

What python keyword do you use to output data from your program to your user?

Print

19
New cards

Complete the code below to output Hello followed by their name:

name = input("What's your name?")
#your code goes here

print("Hello", name)
OR
print("Hello "+name)

20
New cards

What type of data does an integer hold?

Whole numbers (including negative numbers and 0)

21
New cards

What type of data does a float/real hold?

Decimal numbers

22
New cards

What type of data does a string hold?

Text, punctuation, numbers, symbols - anything stored in a ""

23
New cards

What type of data does a Boolean hold?

True / False
1 / 0

24
New cards

What is the output of the code below?
print(int(101.1))

101 (casting a float as an integer will remove the decimal numbers)

25
New cards

What is the output of the code below?
print(int(42.99))

42 (casting a float as an integer will remove the decimal numbers)

26
New cards

Define the term casting

Changing a variable's data type

27
New cards

What is a list used for?

Storing multiple pieces of data under a single name.

example:
Names
Lucki
Matt
Hiten
Aoife

28
New cards

Define the term sequence

Executing instructions in order

29
New cards

Define the term syntax error

An error that does cause the program to crash. An error in the rules of the programming language.

30
New cards

Define the term logic error

An error that does not cause the program to crash or produces unexpected output

31
New cards

Define the term IDE (Integrated Development Environment)​

Allows programmers to write, test and run their programs. ​

32
New cards

Define the term selection

A comparison is made and the algorithm branches based on the result (can execute different pieces of code)

33
New cards

What is the output of this code?
number = 5
if number < 10:
number = number * 2
else:
number = number / 2
print(number)

10

34
New cards

What is the output of this code?
number = 18
if number < 10:
number = number * 2
else:
number = number / 2
print(number)

9

35
New cards

What do all selection statements start with?

if

36
New cards

What key term is missing from the code extract below?

if number < 5:
print("your number is less than 5")
____ number < 10:
print("Your number is less than 10")

elif

37
New cards

What key term is missing from the code extract below?

if number =< 5:
print("your number is 5 or less")
____:
print("Your number is greater than 5")

else

38
New cards

Does else have a condition?

No

39
New cards

How many If statements can you have in 1 block of selection statements?

1 (if starts a new selection block)

40
New cards

How many elif statements can you have in 1 block of selection statements?

Unlimited

41
New cards

Define the term iteration

Part of an algorithm is looped if a certain condition is met

42
New cards

Name the 2 types of loop

while and for

43
New cards

Name the boolean operators you can use in a program

AND, OR, NOT

44
New cards

Why should you use comments in your code?

Make it easier to follow the logic of your code.
Explain how the code works.
Add details like the version number.
To help someone else edit your code or to help someone else edit your code (maintainability)

45
New cards

What numbers will this code output?

for count in range(0,10):
print(count)

0
1
2
3
4
5
6
7
8
9

46
New cards

A for loop is what type of loop?

Counter controlled Iteration / loop

47
New cards

A while loop is what type of loop?

Conditional iteration / loop

48
New cards

Define compression

Reducing the size of a fil4

49
New cards

Name the 2 types of compression

Lossy and Lossless

50
New cards

Define lossy compression

Compression in which data is lost and cannot be retrieved in its original form.

51
New cards

Define lossless compression

Compression in which no data is lost and all data can be retrieved in its original form.

52
New cards

What type of file would you use lossy for?

Used for media (images, videos, sound) where a loss of detail isn't noticeable to the eye/ear.

53
New cards

What type of file would you use lossless for?

Text and programs as a loss of data means the file wouldn't work correctly.

54
New cards

Why do we compress files?

Reduce the file size
Less data means the file is quicker to send
Means you can store more files on secondary storage

55
New cards

Define the term bit

A single binary digit, either 1 or 0

56
New cards

Define the term byte

8 bits of data

57
New cards

Define the term nibble

4 bits of data

58
New cards

How many nibbles in a byte?

2 (1 nibble is 4 bits, 1 byte is 8 bits therefore 8 / 4 is 2)

59
New cards

When storing data, what does KB stand for?

Kilobyte

60
New cards

When storing data, what does GB stand for?

Gigabyte

61
New cards

When storing data, what does MB stand for?

Megabyte

62
New cards

How many bytes in a kilobyte?

1024

63
New cards

Order these storage units from smallest to biggest: nibble, bit, kilobyte, gigabyte, byte, megabyte

bit, nibble, byte, kilobyte, megabyte and gigabyte

64
New cards

Order these storage units from largest to smallest: nibble, bit, kilobyte, gigabyte, byte, megabyte

Gigabyte, megabyte, kilobyte, byte, nibble and bit

65
New cards

How many kilobits in a megabyte?

1024

66
New cards

How many megabytes in a gigabyte?

1024